From c67d9294d20d8a524f8a8f0df7936a6833c53985 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Tue, 30 Jan 2024 10:56:58 -0500 Subject: [PATCH] cmake fuckery --- CMakeLists.txt | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d91ef1a..c89645f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,22 +7,43 @@ 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") +add_dependencies(BLT stats_lib_bindings_rust) + 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 -Werror -Wpedantic -Wno-comment -Wno-unused-parameter) target_link_options(gp_image_test PRIVATE -Wall -Wextra -Werror -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_SOURCE_DIR}/extern/bindings/target/release/libbindings.so) + target_link_libraries(gp_image_test ${CMAKE_CURRENT_BINARY_DIR}/libbindings.so) else () - target_link_libraries(gp_image_test ${CMAKE_SOURCE_DIR}/extern/bindings/target/release/libbindings.a) + target_link_libraries(gp_image_test ${CMAKE_CURRENT_BINARY_DIR}/libbindings.a) endif () if (${ENABLE_ADDRSAN} MATCHES ON)