Skip to content

Commit

Permalink
#1765: CMake: set compilation flags when loading libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed May 9, 2022
1 parent f1a3cc2 commit ea9bb8e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ get_directory_property(hasParent PARENT_DIRECTORY)
include(cmake/check_system_functions.cmake)

set(VIRTUAL_TRANSPORT_LIBRARY vt CACHE INTERNAL "" FORCE )
set(FCONTEXT_LIBRARY fcontext)

# Set the local module path so custom cmake scripts can be located automatically
set(
Expand Down
10 changes: 9 additions & 1 deletion cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Bundled dependencies

include(SetCXXCompilerFlags)

# Export a minimum version flag for any bundled libraries that don't set their own
set(CMAKE_CXX_STANDARD 14)

Expand All @@ -9,11 +10,14 @@ if (vt_libfort_enabled)
set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "")
add_subdirectory(${PROJECT_LIB_DIR}/libfort)
set(FORT_LIBRARY fort)
set_darma_compiler_flags(${FORT_LIBRARY})
endif()

# Optionally include fcontext
if (vt_fcontext_enabled)
set(FCONTEXT_LIBRARY fcontext)
add_subdirectory(${PROJECT_LIB_DIR}/context)
set_darma_compiler_flags(${FCONTEXT_LIBRARY})
endif()

# CLI11 always included in the build
Expand All @@ -22,10 +26,12 @@ add_subdirectory(${PROJECT_LIB_DIR}/CLI)
# fmt always included in the build
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
set_darma_compiler_flags(${FMT_LIBRARY})

# EngFormat-Cpp always included in the build
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)
add_subdirectory(${PROJECT_LIB_DIR}/EngFormat-Cpp)
set_darma_compiler_flags(${ENG_FORMAT_LIBRARY})

# json library always included in the build
set(JSON_BuildTests OFF)
Expand All @@ -40,6 +46,7 @@ set(BROTLI_BUNDLED_MODE OFF)
set(BROTLI_BUILD_PORTABLE ON)
set(BROTLI_LIBRARY brotlicommon-static brotlienc-static brotlidec-static)
add_subdirectory(${PROJECT_LIB_DIR}/brotli)
set_darma_compiler_flags(${BROTLI_LIBRARY})

# Optionally include mimalloc (alternative memory allocator)
if (vt_mimalloc_enabled)
Expand All @@ -49,6 +56,7 @@ if (vt_mimalloc_enabled)
else()
set(MIMALLOC_LIBRARY mimalloc)
endif()
set_darma_compiler_flags(${MIMALLOC_LIBRARY})
endif()

# Check if sanitizers can be enabled
Expand Down
19 changes: 2 additions & 17 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,30 +317,15 @@ install(
COMPONENT runtime
)

set_darma_compiler_flags(${FMT_LIBRARY})
install(TARGETS ${FMT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

set_darma_compiler_flags(${ENG_FORMAT_LIBRARY})
install(TARGETS ${ENG_FORMAT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

set_darma_compiler_flags(${BROTLI_LIBRARY})
install(TARGETS ${BROTLI_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

install(TARGETS ${ENG_FORMAT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})
install(TARGETS ${FMT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})
install(TARGETS ${JSON_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

if (vt_mimalloc_enabled)
set_darma_compiler_flags(${MIMALLOC_LIBRARY})
endif()

if (vt_libfort_enabled)
set_darma_compiler_flags(${FORT_LIBRARY})
install(TARGETS ${FORT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})
endif()

if (vt_fcontext_enabled)
set_darma_compiler_flags(${FCONTEXT_LIBRARY})
endif()

# Export to build directory
export(
TARGETS ${VIRTUAL_TRANSPORT_LIBRARY}
Expand Down

0 comments on commit ea9bb8e

Please sign in to comment.