Skip to content

Commit

Permalink
CMake: Fix model debug builds
Browse files Browse the repository at this point in the history
Debug flags were set too late so that most of the model extension was built without them.
  • Loading branch information
dweindl committed Dec 1, 2023
1 parent c174c40 commit 983bb82
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/CMakeLists.template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ find_package(Amici TPL_AMICI_VERSION REQUIRED HINTS
${CMAKE_CURRENT_LIST_DIR}/../../build)
message(STATUS "Found AMICI ${Amici_DIR}")

# Debug build?
if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
add_compile_options(-UNDEBUG -O0 -g)
set(CMAKE_BUILD_TYPE "Debug")
endif()

# coverage options
if($ENV{ENABLE_GCOV_COVERAGE})
string(APPEND CMAKE_CXX_FLAGS_DEBUG " --coverage")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " --coverage")
endif()

set(MODEL_DIR ${CMAKE_CURRENT_LIST_DIR})

set(SRC_LIST_LIB TPL_SOURCES ${MODEL_DIR}/wrapfunctions.cpp)
Expand Down Expand Up @@ -66,18 +78,6 @@ if(NOT "${AMICI_PYTHON_BUILD_EXT_ONLY}")
target_link_libraries(simulate_${PROJECT_NAME} ${PROJECT_NAME})
endif()

# Debug build?
if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
add_compile_options(-UNDEBUG -O0 -g)
set(CMAKE_BUILD_TYPE "Debug")
endif()

# coverage options
if($ENV{ENABLE_GCOV_COVERAGE})
string(APPEND CMAKE_CXX_FLAGS_DEBUG " --coverage")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " --coverage")
endif()

# SWIG
option(ENABLE_SWIG "Build swig/python library?" ON)
if(ENABLE_SWIG)
Expand Down

0 comments on commit 983bb82

Please sign in to comment.