From 8bf7c6fd79c5955bb7cfb9f8659b22985b6dc42f Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 16 Oct 2025 14:09:38 +0200 Subject: [PATCH] cmake auto copy libsim_* and libui_* to bin folder --- client/CMakeLists.txt | 53 +++++++++++++++++++++++-------------------- server/CMakeLists.txt | 6 ++++- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9e27ff8..feba4cd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -25,30 +25,6 @@ set(PROJECT_SOURCES web_socket_wrapper.hpp ) -if (NOT EMSCRIPTEN) - file(GLOB_RECURSE sims "simulators/*.cpp") - # Loop through each .cpp file and create a library for it - foreach(sim ${sims}) - # Extract the base name of the file (without the directory and extension) - get_filename_component(LIB_NAME ${sim} NAME_WE) - - # Create a library for each .cpp file - add_library(ui_${LIB_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.hpp ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.ui) - target_link_libraries(ui_${LIB_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets magic_enum::magic_enum nlohmann_json::nlohmann_json) - target_include_directories(ui_${LIB_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ui ${CMAKE_SOURCE_DIR}/external/qwt/src ${CMAKE_SOURCE_DIR}/external/spdlog/include ${PROJECT_BINARY_DIR}/) - - set_target_properties( - ui_${LIB_NAME} - PROPERTIES - AUTOUIC ON - AUTOMOC ON - AUTORCC ON - ) - endforeach() -else() - file(GLOB_RECURSE sims "simulators/*") -endif() - if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(unisim_client MANUAL_FINALIZATION @@ -116,3 +92,32 @@ install(TARGETS Simulator-CVS_I10 if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(unisim_client) endif() + +if (NOT EMSCRIPTEN) + file(GLOB_RECURSE sims "simulators/*.cpp") + # Loop through each .cpp file and create a library for it + foreach(sim ${sims}) + # Extract the base name of the file (without the directory and extension) + get_filename_component(LIB_NAME ${sim} NAME_WE) + + # Create a library for each .cpp file + add_library(ui_${LIB_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.hpp ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.ui) + target_link_libraries(ui_${LIB_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets magic_enum::magic_enum nlohmann_json::nlohmann_json) + target_include_directories(ui_${LIB_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ui ${CMAKE_SOURCE_DIR}/external/qwt/src ${CMAKE_SOURCE_DIR}/external/spdlog/include ${PROJECT_BINARY_DIR}/) + + set_target_properties( + ui_${LIB_NAME} + PROPERTIES + AUTOUIC ON + AUTOMOC ON + AUTORCC ON + ) + + add_custom_command(TARGET ui_${LIB_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) + endforeach() +else() + file(GLOB_RECURSE sims "simulators/*") +endif() \ No newline at end of file diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index ede289a..544d367 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -77,4 +77,8 @@ foreach(sim ${sims}) add_library(sim_${LIB_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.hpp ${CMAKE_CURRENT_SOURCE_DIR}/simulators/${LIB_NAME}.cpp) target_link_libraries(sim_${LIB_NAME} PRIVATE Qt::SerialBus magic_enum::magic_enum nlohmann_json::nlohmann_json) target_include_directories(sim_${LIB_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/CAN ${CMAKE_SOURCE_DIR}/VISA ${CMAKE_SOURCE_DIR}/GPIO ${CMAKE_SOURCE_DIR}/UI ${CMAKE_SOURCE_DIR}/external/color ${CMAKE_SOURCE_DIR}/external/spdlog/include) -endforeach() + add_custom_command(TARGET sim_${LIB_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endforeach() \ No newline at end of file