1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-11-24 13:31:05 +00:00

CMake: Minor debug refactoring

- LAIKA_DEBUG_BUILD is set to true if lower(CMAKE_BUILD_TYPE) matches 'debug'
This commit is contained in:
CPunch 2022-06-05 15:51:18 -05:00
parent a410a9ac15
commit 87f5eaa694
2 changed files with 4 additions and 2 deletions

View File

@ -30,6 +30,7 @@ endif ()
string(TOLOWER ${CMAKE_BUILD_TYPE} RAWCMAKEBUILDTYPE) string(TOLOWER ${CMAKE_BUILD_TYPE} RAWCMAKEBUILDTYPE)
message(STATUS "CMAKE_BUILD_TYPE: " ${RAWCMAKEBUILDTYPE}) message(STATUS "CMAKE_BUILD_TYPE: " ${RAWCMAKEBUILDTYPE})
if(RAWCMAKEBUILDTYPE STREQUAL "debug") if(RAWCMAKEBUILDTYPE STREQUAL "debug")
set(LAIKA_DEBUG_BUILD on)
if(WIN32) if(WIN32)
# statically link debug libs for windows # statically link debug libs for windows
message(STATUS "Adding MSVC Debug libs...") message(STATUS "Adding MSVC Debug libs...")
@ -44,6 +45,7 @@ if(RAWCMAKEBUILDTYPE STREQUAL "debug")
add_link_options(-fsanitize=address) add_link_options(-fsanitize=address)
endif () endif ()
else() else()
set(LAIKA_DEBUG_BUILD off)
# statically link non-debug libs # statically link non-debug libs
if(WIN32) if(WIN32)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")

View File

@ -14,7 +14,7 @@ file(GLOB_RECURSE BOTHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
# include platform specific backends # include platform specific backends
if(WIN32) if(WIN32)
file(GLOB_RECURSE BOTPLATFORMSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/win/**.c) file(GLOB_RECURSE BOTPLATFORMSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/win/**.c)
if (NOT RAWCMAKEBUILDTYPE STREQUAL "debug") if (NOT LAIKA_DEBUG_BUILD)
set(BOTFLAGS WIN32) set(BOTFLAGS WIN32)
endif () endif ()
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
@ -37,7 +37,7 @@ target_compile_definitions(LaikaBot PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
target_include_directories(LaikaBot PUBLIC ${BOT_INCLUDEDIR}) target_include_directories(LaikaBot PUBLIC ${BOT_INCLUDEDIR})
# strip symbols for UNIX binaries # strip symbols for UNIX binaries
if((UNIX AND NOT APPLE) AND NOT RAWCMAKEBUILDTYPE STREQUAL "debug") if((UNIX AND NOT APPLE) AND NOT LAIKA_DEBUG_BUILD)
message(STATUS "Stripping LaikaBot symbols...") message(STATUS "Stripping LaikaBot symbols...")
target_link_options(LaikaBot PRIVATE -s) target_link_options(LaikaBot PRIVATE -s)
endif () endif ()