Skip to content

Commit

Permalink
Merge pull request #1 from hpc4cmb/static
Browse files Browse the repository at this point in the history
Support installation of a static library.
  • Loading branch information
tskisner authored May 26, 2020
2 parents f6228f9 + b321216 commit 94d8127
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
32 changes: 24 additions & 8 deletions src/libaatm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Name of the internal static library
set(AATM_LIB aatm_)
# Name of the static library
set(AATM_STATIC aatm_static)

# Name of loadable module / shared library
set(AATM_MOD aatm)
Expand Down Expand Up @@ -29,26 +29,42 @@ set(AATM_SOURCES
src/ATMWVRMeasurement.cpp
)

# Add the internal library target
# Add the internal object library target

add_library(${AATM_LIB} STATIC ${AATM_SOURCES})
add_library(aatmobj OBJECT ${AATM_SOURCES})
set_property(TARGET aatmobj PROPERTY POSITION_INDEPENDENT_CODE 1)

target_include_directories(${AATM_LIB} PUBLIC
target_include_directories(aatmobj PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
src
)

# Static library

add_library(${AATM_STATIC} STATIC $<TARGET_OBJECTS:aatmobj>)

target_include_directories(${AATM_STATIC} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src
)

# Now define rules for the shared library

add_library(${AATM_MOD} SHARED ${AATM_SOURCES})
add_library(${AATM_MOD} SHARED $<TARGET_OBJECTS:aatmobj>)

target_include_directories(${AATM_MOD} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE .
PRIVATE src
)

install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(TARGETS ${AATM_MOD} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(
TARGETS
${AATM_MOD}
${AATM_STATIC}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Name of the internal static library
set(AATM_LIB aatm_)
set(AATM_LIB aatm_static)

#======================================================

Expand Down

0 comments on commit 94d8127

Please sign in to comment.