diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b6f48f..24c92e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,33 @@ message("-- CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") message("-- CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") message("-- CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") +# Libraries find_package(raylib REQUIRED) +set(LIBS raylib) +set(FLAGS "") + +if(NOT DEFINED DISABLE_BACKWARD) + find_package(Backward REQUIRED) + + list(APPEND LIBS Backward::Backward) + list(APPEND FLAGS BACKWARD) +endif() + +if(NOT DEFINED DISABLE_TRACY) + include(FetchContent) + FetchContent_Declare(tracy + GIT_REPOSITORY https://github.com/wolfpld/tracy.git + GIT_TAG v0.11.1 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + ) + FetchContent_MakeAvailable(tracy) + option(TRACY_ENABLE "" ON) + option(TRACY_ON_DEMAND "" ON) + + list(APPEND LIBS TracyClient) + list(APPEND FLAGS TRACY) +endif() # Headers + Sources include_directories(include) @@ -36,38 +62,9 @@ set(SOURCES # Main target add_executable(masssprings ${SOURCES}) -target_include_directories(masssprings PUBLIC ${RAYLIB_CPP_INCLUDE_DIR}) -if(NOT DEFINED DISABLE_BACKWARD) - find_package(Backward REQUIRED) - target_link_libraries(masssprings PUBLIC raylib Backward::Backward) - target_compile_definitions(masssprings PUBLIC BACKWARD) -else() - target_link_libraries(masssprings PUBLIC raylib) -endif() - -# Tracy target -if(NOT DEFINED DISABLE_TRACY) - include(FetchContent) - FetchContent_Declare(tracy - GIT_REPOSITORY https://github.com/wolfpld/tracy.git - GIT_TAG v0.11.1 - GIT_SHALLOW TRUE - GIT_PROGRESS TRUE - ) - FetchContent_MakeAvailable(tracy) - option(TRACY_ENABLE "" ON) - option(TRACY_ON_DEMAND "" ON) - - add_executable(masssprings_tracy ${SOURCES}) - target_include_directories(masssprings_tracy PUBLIC ${RAYLIB_CPP_INCLUDE_DIR}) - target_compile_definitions(masssprings_tracy PRIVATE TRACY) - if(NOT DEFINED DISABLE_BACKWARD) - target_link_libraries(masssprings_tracy PUBLIC raylib Backward::Backward TracyClient) - target_compile_definitions(masssprings_tracy PUBLIC BACKWARD) - else() - target_link_libraries(masssprings_tracy PUBLIC raylib TracyClient) - endif() -endif() +target_include_directories(masssprings PRIVATE ${RAYLIB_CPP_INCLUDE_DIR}) +target_link_libraries(masssprings PRIVATE ${LIBS}) +target_compile_definitions(masssprings PRIVATE ${FLAGS}) # LTO if (NOT WIN32) diff --git a/compile_commands.json b/compile_commands.json index fd9db9d..66636ac 120000 --- a/compile_commands.json +++ b/compile_commands.json @@ -1 +1 @@ -./cmake-build-release/compile_commands.json \ No newline at end of file +./cmake-build-debug/compile_commands.json \ No newline at end of file diff --git a/flake.nix b/flake.nix index 6f72931..2c0698c 100644 --- a/flake.nix +++ b/flake.nix @@ -295,7 +295,7 @@ rec { abbr -a debug-clean "${cmakeDebug} && ${buildDebug} && ./cmake-build-debug/masssprings" abbr -a release-clean "${cmakeRelease} && ${buildRelease} && ./cmake-build-release/masssprings" abbr -a rungdb "${buildDebug} && gdb --tui ./cmake-build-debug/masssprings" - abbr -a runtracy "tracy -a 127.0.0.1 &; ${buildRelease} && sudo -E ./cmake-build-release/masssprings_tracy" + abbr -a runtracy "tracy -a 127.0.0.1 &; ${buildRelease} && sudo -E ./cmake-build-release/masssprings" abbr -a runvalgrind "${buildDebug} && valgrind --leak-check=full --show-reachable=no --show-leak-kinds=definite,indirect,possible --track-origins=no --suppressions=valgrind.supp --log-file=valgrind.log ./cmake-build-debug/masssprings && cat valgrind.log" ''; in