Skip to content

Commit

Permalink
Updates to build system
Browse files Browse the repository at this point in the history
- Add "Info" custom build type which turns down the debug level

- Add option to compile with thread-local task handle storage
  (currently off by default)
  • Loading branch information
adamtuft committed Apr 29, 2024
1 parent 304f8d9 commit 54a0a6d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/lib/fmod)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/ar)

# Custom Info build type is the same as Debug, but uses a different logging level
set(CMAKE_C_FLAGS_INFO "${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_INFO "${CMAKE_CXX_FLAGS_DEBUG}")

# Absolutely required
find_package(OTF2)
message(VERBOSE "OTF2_ROOT: ${OTF2_ROOT}")
Expand All @@ -45,6 +49,14 @@ configure_file(
${PROJECT_BINARY_DIR}/include/public/config.h # write to build tree
)

add_library(Otter::debug_level IMPORTED INTERFACE)
target_compile_definitions(Otter::debug_level INTERFACE
$<IF:$<CONFIG:Debug>, DEBUG_LEVEL=3,
$<IF:$<CONFIG:Info>, DEBUG_LEVEL=2,
$<IF:$<CONFIG:Release>, DEBUG_LEVEL=1,
$<IF:$<CONFIG:RelWithDebInfo>, DEBUG_LEVEL=1, DEBUG_LEVEL=0>>>>
)

add_subdirectory(src/types)
add_subdirectory(src/otter-trace)
add_subdirectory(src/otter-task-graph)
Expand Down
26 changes: 26 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"build-release"
]
},
{
"name": "clang-info",
"displayName": "Clang (info)",
"inherits": [
"common",
"compiler-clang",
"build-info"
]
},
{
"name": "clang-debug",
"displayName": "Clang (debug)",
Expand Down Expand Up @@ -46,6 +55,15 @@
"build-release"
]
},
{
"name": "gcc-info",
"displayName": "GCC (info)",
"inherits": [
"common",
"compiler-gcc",
"build-info"
]
},
{
"name": "gcc-debug",
"displayName": "GCC (debug)",
Expand All @@ -71,6 +89,10 @@
"name": "clang-release",
"configurePreset": "clang-release"
},
{
"name": "clang-info",
"configurePreset": "clang-info"
},
{
"name": "clang-debug",
"configurePreset": "clang-debug"
Expand All @@ -83,6 +105,10 @@
"name": "gcc-release",
"configurePreset": "gcc-release"
},
{
"name": "gcc-info",
"configurePreset": "gcc-info"
},
{
"name": "gcc-debug",
"configurePreset": "gcc-debug"
Expand Down
11 changes: 10 additions & 1 deletion cmake/CMakePresetBases.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_Fortran_FLAGS": "-ffree-line-length-512"
"CMAKE_Fortran_FLAGS": "-ffree-line-length-512",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"WITH_THREAD_LOCAL_TASK_HANDLE": "ON"
}
},
{
Expand Down Expand Up @@ -54,6 +56,13 @@
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "build-info",
"hidden": true,
"environment": {
"CMAKE_BUILD_TYPE": "Info"
}
},
{
"name": "build-debug",
"hidden": true,
Expand Down
3 changes: 1 addition & 2 deletions src/otter-task-graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ target_include_directories(otter-task-graph
)

target_link_libraries(otter-task-graph
PRIVATE Otter::debug_level
PRIVATE otter-trace otter-dtype
INTERFACE OTF2::otf2 pthread # add to the link interface for consumers of otter-task-graph
)

target_compile_definitions(otter-task-graph PRIVATE DEBUG_LEVEL=$<IF:$<CONFIG:Debug>,3,0>)

foreach(_HEADER IN ITEMS otter-task-graph-user.h otter-task-graph.h otter-task-graph-stub.h)
list(APPEND OTTER_TASK_GRAPH_PUBLIC_HEADERS "${PROJECT_SOURCE_DIR}/include/api/otter-task-graph/${_HEADER}")
endforeach()
Expand Down
3 changes: 1 addition & 2 deletions src/otter-trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ target_include_directories(otter-trace
)

target_link_libraries(otter-trace
PRIVATE Otter::debug_level
PUBLIC OTF2::otf2 # some otter-trace public headers include OTF2
)

target_compile_definitions(otter-trace PRIVATE DEBUG_LEVEL=$<IF:$<CONFIG:Debug>,3,0>)

set_property(TARGET otter-trace PROPERTY POSITION_INDEPENDENT_CODE ON)

install(TARGETS otter-trace
Expand Down
5 changes: 1 addition & 4 deletions src/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ target_include_directories(otter-dtype
PRIVATE ${PROJECT_SOURCE_DIR}/include # for all other includes
)

target_compile_definitions(otter-dtype
PRIVATE
DEBUG_LEVEL=$<IF:$<CONFIG:Verbose>,3,0>
)
target_link_libraries(otter-dtype PRIVATE Otter::debug_level)

set_property(TARGET otter-dtype PROPERTY POSITION_INDEPENDENT_CODE ON)

Expand Down

0 comments on commit 54a0a6d

Please sign in to comment.