Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake install target #286

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ option(USE_MFEM "Build libROM with MFEM" OFF)
option(MFEM_USE_GSLIB "Build libROM with MFEM using GSLIB" OFF)
option(BUILD_STATIC "Build libROM as a static library" OFF)
option(ENABLE_EXAMPLES "Build examples and regression tests" ON)
option(ENABLE_DOCS "Build docs using Doxygen" OFF)

## Set a bunch of variables to generate a configure header
# Enable assertion checking if debug symbols generated
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR
(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
set(DEBUG_CHECK_ASSERTIONS "1")
endif((CMAKE_BUILD_TYPE STREQUAL "Debug") OR
(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

set(CAROM_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CAROM_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
Expand Down Expand Up @@ -107,8 +109,6 @@ find_package(MPI 1.2 REQUIRED)

find_package(ZLIB 1.2.3 REQUIRED)

find_package(Doxygen 1.8.5)

find_package(GTest 1.6.0)

if (USE_MFEM)
Expand Down Expand Up @@ -297,7 +297,9 @@ endif(GTEST_FOUND)
# NOTE(goxberry@gmail.com, oxberry1@llnl.gov): This code snippet
# builds the Doxygen documentation, but outputs said documentation to
# ${CMAKE_CURRENT_SOURCE_DIR}/docs)...
if(DOXYGEN_FOUND)
if(${ENABLE_DOCS})
find_package(Doxygen 1.8.5 REQUIRED)

set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile)

add_custom_target(
Expand All @@ -316,4 +318,4 @@ if(DOXYGEN_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/docs/html/rom.tag)
add_dependencies(doxygen_tagfile documentation)

endif(DOXYGEN_FOUND)
endif()
23 changes: 22 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ set(module_list
utils/mpi_utils)
set(source_files)
foreach(module IN LISTS module_list)
list(APPEND source_files ${module}.cpp)
list(APPEND source_files ${module}.cpp ${module}.h)
endforeach(module) # IN LISTS module_list

list(APPEND source_files
Expand Down Expand Up @@ -141,3 +141,24 @@ target_include_directories(ROM PUBLIC
${MPI_C_INCLUDE_DIRS}
${MFEM_C_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Find headers from the source file list that need to be installed
set(HEADERS "")
foreach(file IN LISTS source_files)
if(file MATCHES ".(hpp|h)$")
list(APPEND HEADERS ${file})
endif()
endforeach(file)

# Only install libROM.so if installing to a different directory. Otherwise, libROM.so is already in lib/
if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL ${CMAKE_BINARY_DIR})
install(TARGETS ROM EXPORT ROM LIBRARY DESTINATION lib INCLUDES DESTINATION include)
endif()

# Install libROM headers
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/CAROM_config.h ${CMAKE_CURRENT_SOURCE_DIR}/FCMangle.h DESTINATION include)
foreach(file IN LISTS HEADERS)
# get the directory component so the include directory structure is preserved
get_filename_component(dir ${file} DIRECTORY)
install(FILES ${file} DESTINATION include/${dir})
endforeach(file)
Loading