Skip to content

Commit 5c14e3b

Browse files
committed
build: hoist profiling flags and debug macros up
This pulls the global configuration up to the top level. Avoid touching the user controlled variables.
1 parent 2e5584c commit 5c14e3b

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ if(CMAKE_BUILD_TYPE STREQUAL "Ubsan")
5050
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fsanitize=undefined>)
5151
endif()
5252

53+
# Check integrity of node structure when compiled as debug
54+
add_compile_definitions($<$<CONFIG:Debug>:CMARK_DEBUG_NODES>)
55+
# FIXME(compnerd) why do we not use `!defined(NDEBUG)`?
56+
add_compile_definitions($<$<CONFIG:Debug>:DEBUG>)
57+
58+
add_compile_options($<$<AND:$<CONFIG:PROFILE>,$<COMPILE_LANGUAGE:C>>:-pg>)
59+
5360
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
5461
message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
5562
endif()

extensions/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ include_directories(
1919

2020
include_directories(include ${CMAKE_CURRENT_BINARY_DIR})
2121

22-
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
23-
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
24-
2522
if (CMARK_SHARED)
2623
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
2724

src/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ elseif(CMARK_STATIC)
5555
target_link_libraries(${PROGRAM} libcmark-gfm-extensions_static libcmark-gfm_static)
5656
endif()
5757

58-
# Check integrity of node structure when compiled as debug:
59-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCMARK_DEBUG_NODES -DDEBUG")
60-
set(CMAKE_LINKER_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG}")
61-
62-
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
63-
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
64-
6558
if (CMARK_SHARED)
6659
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
6760
target_include_directories(${LIBRARY} PUBLIC

0 commit comments

Comments
 (0)