diff options
author | Hennadii Chernyshchyk <genaloner@gmail.com> | 2021-10-03 17:30:37 +0300 |
---|---|---|
committer | Hennadii Chernyshchyk <genaloner@gmail.com> | 2021-10-03 17:30:37 +0300 |
commit | 2f92b4a37de978e5dd289ce6c2aaa1388458cc54 (patch) | |
tree | 40bf87b39c9936982e91445add7105d3c4bb67f7 /CMakeLists.txt | |
parent | 230fd4bc08fa26cafcf77a89e51d5b4b969a27fb (diff) | |
download | redot-cpp-2f92b4a37de978e5dd289ce6c2aaa1388458cc54.tar.gz |
Rework debug flags for CMake
* Attach debug flags to the target and mark as `PUBLIC`. This will allow all
projects that use bindings not to add the same defines manually.
* Use generator-expressions to support multiconfig generators (such as
MSVC).
* Remove excplitic `NDEBUG` and `_DEBUG` flags, CMake handles it
automatically.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7138a4b..772d29f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,14 +44,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE Debug) endif() -if(CMAKE_BUILD_TYPE MATCHES Debug) - add_definitions(-D_DEBUG) - add_definitions(-DDEBUG_ENABLED) - add_definitions(-DDEBUG_METHODS_ENABLED) -else() - add_definitions(-DNDEBUG) -endif(CMAKE_BUILD_TYPE MATCHES Debug) - # Set the c++ standard to c++17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -155,8 +147,11 @@ add_library(${PROJECT_NAME} ${GENERATED_FILES_LIST} ) add_library(godot::cpp ALIAS ${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} - PUBLIC +target_compile_definitions(${PROJECT_NAME} PUBLIC + $<$<CONFIG:Debug>:DEBUG_ENABLED> + $<$<CONFIG:Debug>:DEBUG_METHODS_ENABLED> +) +target_include_directories(${PROJECT_NAME} PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/gen/include ) |