cmake_minimum_required(VERSION 3.25) project(gp_image_test) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) set(CMAKE_CXX_STANDARD 17) set(CARGO_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/bindings) set(CARGO_TOML ${CARGO_WORKING_DIR}/Cargo.toml) set(CARGO_CMD_PATH /home/brett/.cargo/bin/cargo) set(CARGO_COMMAND ${CARGO_CMD_PATH} build --manifest-path ${CARGO_TOML} --release) set(STATS_LIB_NAME libbindings) set(STATS_LIB_DIR ${CMAKE_SOURCE_DIR}/extern/bindings/target/release) message("Using cargo command '${CARGO_COMMAND}'") add_custom_target(stats_lib_bindings_rust ALL COMMENT "Compiling client module" COMMAND ${CARGO_COMMAND} COMMAND cp ${STATS_LIB_DIR}/${STATS_LIB_NAME}.so ${CMAKE_CURRENT_BINARY_DIR} COMMAND cp ${STATS_LIB_DIR}/${STATS_LIB_NAME}.a ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CARGO_WORKING_DIR}) file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/${STATS_LIB_NAME}.so) file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/${STATS_LIB_NAME}.a) add_subdirectory(libraries/BLT-With-Graphics-Template) include_directories(include/) file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") #set(META_LIBS common/pdqhashtypes.cpp io/hashio.cpp common/pdqhamming.cpp hashing/pdqhashing.cpp downscaling/downscaling.cpp hashing/torben.cpp) #include_directories(libraries/ThreatExchange) # #list(TRANSFORM META_LIBS PREPEND ${CMAKE_SOURCE_DIR}/libraries/ThreatExchange/pdq/cpp/) add_executable(gp_image_test ${PROJECT_BUILD_FILES}) add_dependencies(gp_image_test stats_lib_bindings_rust) target_compile_options(gp_image_test PRIVATE -Wall -Wextra -Wpedantic -Wno-comment -Wno-unused-parameter) target_link_options(gp_image_test PRIVATE -Wall -Wextra -Wpedantic -Wno-comment -Wno-unused-parameter) target_link_libraries(gp_image_test BLT_WITH_GRAPHICS) if (${BUILD_SHARED_LIBS}) target_link_libraries(gp_image_test ${CMAKE_CURRENT_BINARY_DIR}/libbindings.so) else () target_link_libraries(gp_image_test ${CMAKE_CURRENT_BINARY_DIR}/libbindings.a) endif () if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(gp_image_test PRIVATE -fsanitize=address) target_link_options(gp_image_test PRIVATE -fsanitize=address) endif () if (${ENABLE_UBSAN} MATCHES ON) target_compile_options(gp_image_test PRIVATE -fsanitize=undefined) target_link_options(gp_image_test PRIVATE -fsanitize=undefined) endif () if (${ENABLE_TSAN} MATCHES ON) target_compile_options(gp_image_test PRIVATE -fsanitize=thread) target_link_options(gp_image_test PRIVATE -fsanitize=thread) endif ()