Skip to content

Commit

Permalink
correctly support external GWB in DebugRelease
Browse files Browse the repository at this point in the history
We incorrectly always only built the debug version of an external GWB
version 0.6 or newer if ASPECT was in DebugRelease mode. With
GeodynamicWorldBuilder/WorldBuilder#686 we can
now configure GWB twice inside the build directory of ASPECT and link to
the correct library.
  • Loading branch information
tjhei committed Feb 28, 2024
1 parent 5296a8b commit bdbfdf3
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,23 @@ if(ASPECT_WITH_WORLD_BUILDER)
MESSAGE(STATUS "Using World Builder version ${WORLD_BUILDER_VERSION} found at ${WORLD_BUILDER_SOURCE_DIR}.")

IF(WORLD_BUILDER_VERSION VERSION_GREATER_EQUAL 0.6.0)
ADD_SUBDIRECTORY("${WORLD_BUILDER_SOURCE_DIR}" ${CMAKE_BINARY_DIR}/world_builder/)
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/world_builder/include/")
IF(${CMAKE_BUILD_TYPE} MATCHES "DebugRelease")
SET(WB_ENABLE_TESTS OFF)
SET(WB_ENABLE_APPS OFF)
SET(WB_ENABLE_HELPER_TARGETS OFF)

SET(CMAKE_BUILD_TYPE Debug)
SET(WB_TARGET "WorldBuilderDebug")
SET(CMAKE_CXX_FLAGS "-g")
ADD_SUBDIRECTORY("${WORLD_BUILDER_SOURCE_DIR}" ${CMAKE_BINARY_DIR}/world_builder/)
SET(CMAKE_BUILD_TYPE Release)
SET(WB_TARGET "WorldBuilderRelease")
SET(CMAKE_CXX_FLAGS "-O3 -DNDEBUG")
ADD_SUBDIRECTORY("${WORLD_BUILDER_SOURCE_DIR}" ${CMAKE_BINARY_DIR}/world_builder_release/)
SET(CMAKE_BUILD_TYPE DebugRelease)
ELSE()
ADD_SUBDIRECTORY("${WORLD_BUILDER_SOURCE_DIR}" ${CMAKE_BINARY_DIR}/world_builder/)
ENDIF()
ELSE()
FILE(GLOB_RECURSE wb_files "${WORLD_BUILDER_SOURCE_DIR}/source/world_builder/*.cc")
LIST(APPEND TARGET_SRC ${wb_files})
Expand Down Expand Up @@ -520,7 +535,7 @@ IF(NOT ASPECT_ADDITIONAL_CXX_FLAGS STREQUAL "")
MESSAGE(STATUS " DEAL_II_CXX_FLAGS_RELEASE: ${DEAL_II_CXX_FLAGS_RELEASE}")
ENDIF()

# Provide "release" and "debug" targets to switch compile mode
# Setup targets for ASPECT:
IF(${CMAKE_BUILD_TYPE} MATCHES "DebugRelease")
ADD_EXECUTABLE(${TARGET} ${TARGET_SRC})
DEAL_II_SETUP_TARGET(${TARGET} DEBUG)
Expand Down Expand Up @@ -654,9 +669,19 @@ ELSE()
ENDIF()

IF(WORLD_BUILDER_VERSION VERSION_GREATER_EQUAL 0.6.0 AND ASPECT_WITH_WORLD_BUILDER)
FOREACH(_T ${TARGETS})
TARGET_LINK_LIBRARIES(${_T} WorldBuilder)
ENDFOREACH()
IF(${CMAKE_BUILD_TYPE} MATCHES "DebugRelease")
TARGET_INCLUDE_DIRECTORIES(${TARGET} PUBLIC "${CMAKE_BINARY_DIR}/world_builder/include/")
TARGET_INCLUDE_DIRECTORIES(${TARGET}-release PUBLIC "${CMAKE_BINARY_DIR}/world_builder_release/include/")
TARGET_LINK_LIBRARIES(${TARGET} WorldBuilderDebug)
TARGET_LINK_LIBRARIES(${TARGET}-release WorldBuilderRelease)
target_compile_definitions(${TARGET}-release PUBLIC "NDEBUG")
ELSE()
TARGET_INCLUDE_DIRECTORIES(${TARGET} "${CMAKE_BINARY_DIR}/world_builder/include/")
TARGET_LINK_LIBRARIES(${TARGET} WorldBuilder)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
target_compile_definitions(${TARGET} PUBLIC "NDEBUG")
endif()
ENDIF()
ENDIF()


Expand Down

0 comments on commit bdbfdf3

Please sign in to comment.