diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bc682c05..9ba7d7d07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ option(SRB2_CONFIG_TESTERS "Compile a build for testers." OFF) option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF) option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF) option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF) +option(SRB2_CONFIG_SKIP_COMPTIME "Skip regenerating comptime. To speed up iterative debug builds in IDEs." OFF) # SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting. option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF) option(SRB2_CONFIG_TRACY "Compile with Tracy profiling enabled" OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c46dbf3ce..553cb0e35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,22 +166,24 @@ if(SRB2_CONFIG_ENABLE_WEBM_MOVIES) target_sources(SRB2SDL2 PRIVATE m_avrecorder.cpp) endif() -# This updates the modification time for comptime.c at the -# end of building so when the build system is ran next time, -# that file gets flagged. comptime.c will always be rebuilt. -# -# This begs the question, why always rebuild comptime.c? -# Some things like the git commit must be checked each time -# the program is built. But the build system determines which -# files should be rebuilt before anything else. So -# comptime.c, which only needs to be rebuilt based on -# information known at build time, must be told to rebuild -# before that information can be ascertained. -add_custom_command( - TARGET SRB2SDL2 - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c -) +if(NOT SRB2_CONFIG_SKIP_COMPTIME) + # This updates the modification time for comptime.c at the + # end of building so when the build system is ran next time, + # that file gets flagged. comptime.c will always be rebuilt. + # + # This begs the question, why always rebuild comptime.c? + # Some things like the git commit must be checked each time + # the program is built. But the build system determines which + # files should be rebuilt before anything else. So + # comptime.c, which only needs to be rebuilt based on + # information known at build time, must be told to rebuild + # before that information can be ascertained. + add_custom_command( + TARGET SRB2SDL2 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c + ) +endif() # config.h is generated by this command. It should be done at # build time for accurate git information and before anything @@ -614,10 +616,7 @@ add_subdirectory(hud) # strip debug symbols into separate file when using gcc. # to be consistent with Makefile, don't generate for OS X. if((CMAKE_COMPILER_IS_GNUCC) AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)) - if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) - set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug") - endif() + if(${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo) message(STATUS "Will make separate debug symbols in *.debug") add_custom_command(TARGET SRB2SDL2 POST_BUILD COMMAND ${OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $ $.debug