crossguid
crossguid copied to clipboard
Utilitze JS crypto.createUUID() when compiling with Emscripten
Similar to the other platform defines, emscripten provides a mechanism for calling JS APIs from C++ and all modern browsers provide a secure UUID generation method.
I'm current experimenting with this for a cross platform I'm building, one of which is to WASM but I am not a cmake wizard and am just statically including all the necessary crossguid files in my app with crossguid as a submodule. I can get all the includes and everything straightened out but am not sure of the proper way to nest the crossguid build from another cmake project.
Hi @negentropicdev,
[I am just a user]
In standard CMake practice it could be by using CMake's FetchContent, which handles dependent CMake-based libraries available on public git repositories.
Here is a sample micro-project using it. It should compile fine.
main.cpp
#include "crossguid/guid.hpp"
#include <iostream>
int main()
{
std::cout << "Here is a new GUID : " << xg::newGuid() << std::endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(mySample)
set(CMAKE_CXX_STANDARD 17)
# Using FetchContent to include crossguid
include(FetchContent)
# indicate crossguid's location and version to use
FetchContent_Declare(
crossguid
GIT_REPOSITORY https://github.com/graeme-hill/crossguid.git
GIT_TAG master)
# making available throughout the project
FetchContent_MakeAvailable(crossguid)
add_executable(sample main.cpp)
# add crossguid as dependency (provides both link and include files)
target_link_libraries(sample PRIVATE crossguid)
NOTE:
You will need, in your CMakeLists.txt
, all the 4 lines where I have added a comment line.
Each of those line is standard and needed (include, FetchContent_Declare, FetchContent_MakeAvailable, target_link_libraries).
Would this help ?
Let me know.
Cheers
I would give that a shot but I'm currently relying on changes I've made to support the additional toolchain that aren't in the public repo right now.