Skip to content

Commit

Permalink
Clean up CMakeLists.txt and remove settings for Shared library compil…
Browse files Browse the repository at this point in the history
…ation (see #200)
  • Loading branch information
SSoelvsten committed Oct 26, 2022
1 parent ce0f585 commit 22a1419
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 42 deletions.
33 changes: 18 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,38 @@ if (ADIAR_STATS_EXTRA)
set(ADIAR_STATS ON)
endif (ADIAR_STATS_EXTRA)

message(STATUS " OS: ${CMAKE_SYSTEM_NAME}")
message(STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " C Flags: ${CMAKE_C_FLAGS}")
message(STATUS " CXX Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS " EXE Linker Flags: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS " OS: ${CMAKE_SYSTEM_NAME}")
message(STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(VERBOSE " C Flags: ${CMAKE_C_FLAGS}")
message(VERBOSE " CXX Flags: ${CMAKE_CXX_FLAGS}")
message(VERBOSE " EXE Linker Flags: ${CMAKE_EXE_LINKER_FLAGS}")

message(STATUS " Library Options:")

option(ADIAR_SHARED "Build adiar as a shared library" OFF)
message(STATUS " Shared: ${ADIAR_SHARED}")
message(STATUS " | Shared: ${ADIAR_SHARED}")

option(ADIAR_STATS "Collect statistics" OFF)

message(STATUS " Statistics: ${ADIAR_STATS}")
message(STATUS " | Statistics: ${ADIAR_STATS}")

message(STATUS " Optional targets:")

option(ADIAR_DOCS "Build Documentation for Adiar" ON)
message(STATUS " | Documentation (Doxygen): ${MAIN_PROJECT}")

option(ADIAR_TEST "Build unit tests for adiar" ${MAIN_PROJECT})
message(STATUS " Unit Tests: ${MAIN_PROJECT}")
message(STATUS " | Unit Tests: ${MAIN_PROJECT}")

option(ADIAR_EXAMPLES "Build examples for usage of adiar" ${MAIN_PROJECT})
message(STATUS " Examples: ${MAIN_PROJECT}")
message(STATUS " | Examples: ${MAIN_PROJECT}")

message(STATUS "")

if (ADIAR_SHARED)
message (FATAL_ERROR "Adiar's CMake files do not (yet) support building Adiar as a shared library (GitHuB Issue #200). Any help to do so, would be very much appreciated.")
endif (ADIAR_SHARED)

# ============================================================================ #
# Dependencies
# ============================================================================ #
Expand All @@ -68,15 +77,9 @@ add_subdirectory (external/cnl cnl)
# ============================================================================ #
add_subdirectory (src)

install(DIRECTORY src/adiar
DESTINATION include
FILES_MATCHING REGEX "\\.h$")

# ============================================================================ #
# Documentation
# ============================================================================ #
option(ADIAR_DOCS "Build Documentation for Adiar" ON)

if (ADIAR_DOCS)
add_subdirectory(docs)
endif (ADIAR_DOCS)
Expand Down
39 changes: 12 additions & 27 deletions src/adiar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,27 @@ set(SOURCES
# ============================================================================ #
# Settings
if (ADIAR_SHARED)
add_library(adiar SHARED ${HEADERS} ${SOURCES})
# TODO: GitHub Issue #200
else()
add_library(adiar STATIC ${HEADERS} ${SOURCES})
add_library(${PROJECT_NAME} STATIC ${HEADERS} ${SOURCES})
endif()

if (ADIAR_STATS_EXTRA)
target_compile_definitions(adiar PRIVATE ADIAR_STATS ADIAR_STATS_EXTRA)
elseif (ADIAR_STATS)
target_compile_definitions(adiar PRIVATE ADIAR_STATS)
if (ADIAR_STATS_EXTRA OR ADIAR_STATS)
target_compile_definitions(${PROJECT_NAME} PRIVATE ADIAR_STATS)
endif()

# ============================================================================ #
# Link dependencies
target_link_libraries(adiar tpie)
target_link_libraries(adiar Cnl)
target_link_libraries(${PROJECT_NAME} tpie)
target_link_libraries(${PROJECT_NAME} Cnl)

# ============================================================================ #
# Setup as library

target_include_directories(adiar PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/..)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/..)

set_target_properties(adiar PROPERTIES
set_target_properties(${PROJECT_NAME} PROPERTIES
# Language settings
LINKER_LANGUAGE CXX
C_STANDARD 17
Expand All @@ -138,24 +136,11 @@ set_target_properties(adiar PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_VISIBILITY_PRESET hidden

# Linkage?
FOLDER adiar
# Visual Studio
FOLDER ${PROJECT_NAME}

# Other
# Project Information
VERSION ${PROJECT_VERSION}
POSITION_INDEPENDENT_CODE ON
)

target_compile_features(adiar PUBLIC cxx_std_17)

include(GenerateExportHeader)
generate_export_header(adiar
EXPORT_MACRO_NAME ADIAR_API
)

install(TARGETS adiar
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${LIBLEGACY_INCLUDE_DIRS}
)

0 comments on commit 22a1419

Please sign in to comment.