Skip to content

Commit

Permalink
Merge pull request #1230 from DLR-AMR/feature-export_cmake_compile_co…
Browse files Browse the repository at this point in the history
…mmands

Add option to export cmake compile commands
  • Loading branch information
sandro-elsweijer authored Sep 2, 2024
2 parents 0729371 + 7ca141c commit cc6391d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include( CTest )

option( T8CODE_BUILD_AS_SHARED_LIBRARY "Whether t8code should be built as a shared or a static library" ON )
option( T8CODE_BUILD_PEDANTIC "Compile t8code with `-Wall -pedantic -Werror` as done in the Github CI." OFF )
option( T8CODE_EXPORT_COMPILE_COMMANDS "Export the compile commands as json. Can be used by IDEs for code completion (e.g. intellisense, clangd)" OFF )
option( T8CODE_BUILD_TESTS "Build t8code's automated tests" ON )
option( T8CODE_BUILD_TUTORIALS "Build t8code's tutorials" ON )
option( T8CODE_BUILD_EXAMPLES "Build t8code's examples" ON )
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ function( add_t8_benchmark )
target_include_directories( ${ADD_T8_BENCHMARK_NAME} PRIVATE ${PROJECT_SOURCE_DIR} )
target_link_libraries( ${ADD_T8_BENCHMARK_NAME} PRIVATE T8 SC::SC )

if( T8CODE_EXPORT_COMPILE_COMMANDS )
set_target_properties( ${ADD_T8_BENCHMARK_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_BENCHMARK_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
endfunction()

Expand Down
4 changes: 4 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function( add_t8_example )
target_link_libraries( ${ADD_T8_EXAMPLE_NAME} PRIVATE T8 t8example SC::SC )
target_include_directories( ${ADD_T8_EXAMPLE_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. )

if( T8CODE_EXPORT_COMPILE_COMMANDS )
set_target_properties( ${ADD_T8_EXAMPLE_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
endfunction()

Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
target_compile_definitions( T8 PUBLIC T8_ENABLE_DEBUG )
endif()

if( T8CODE_EXPORT_COMPILE_COMMANDS )
set_target_properties( T8 PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

if( T8CODE_ENABLE_NETCDF )
target_link_libraries( T8 PUBLIC netCDF::netcdf )
target_compile_definitions(T8 PUBLIC
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ function( add_t8_test )
add_executable( ${ADD_T8_TEST_NAME} ${ADD_T8_TEST_SOURCES} )
target_link_libraries( ${ADD_T8_TEST_NAME} PRIVATE T8 gtest pthread)

if( T8CODE_EXPORT_COMPILE_COMMANDS )
set_target_properties( ${ADD_T8_TEST_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

# Split custom test command into a list by whitespace.
# If MPI is enabled, and no custom test command is provided, use mpirun -np 4 as the default command.
# If MPI is not enabled, use the custom test command as is.
Expand Down
4 changes: 4 additions & 0 deletions tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ function( add_t8_tutorial )
target_link_libraries( ${ADD_T8_TUTORIAL_NAME} PRIVATE T8 SC::SC )
target_include_directories( ${ADD_T8_TUTORIAL_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. )

if( T8CODE_EXPORT_COMPILE_COMMANDS )
set_target_properties( ${ADD_T8_TUTORIAL_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_TUTORIAL_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
endfunction()

Expand Down

0 comments on commit cc6391d

Please sign in to comment.