Skip to content

Commit 94d8127

Browse files
authored
Merge pull request #1 from hpc4cmb/static
Support installation of a static library.
2 parents f6228f9 + b321216 commit 94d8127

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/libaatm/CMakeLists.txt

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
# Name of the internal static library
3-
set(AATM_LIB aatm_)
2+
# Name of the static library
3+
set(AATM_STATIC aatm_static)
44

55
# Name of loadable module / shared library
66
set(AATM_MOD aatm)
@@ -29,26 +29,42 @@ set(AATM_SOURCES
2929
src/ATMWVRMeasurement.cpp
3030
)
3131

32-
# Add the internal library target
32+
# Add the internal object library target
3333

34-
add_library(${AATM_LIB} STATIC ${AATM_SOURCES})
34+
add_library(aatmobj OBJECT ${AATM_SOURCES})
35+
set_property(TARGET aatmobj PROPERTY POSITION_INDEPENDENT_CODE 1)
3536

36-
target_include_directories(${AATM_LIB} PUBLIC
37+
target_include_directories(aatmobj PRIVATE
38+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
39+
$<INSTALL_INTERFACE:include>
40+
src
41+
)
42+
43+
# Static library
44+
45+
add_library(${AATM_STATIC} STATIC $<TARGET_OBJECTS:aatmobj>)
46+
47+
target_include_directories(${AATM_STATIC} PUBLIC
3748
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
3849
$<INSTALL_INTERFACE:include>
3950
PRIVATE src
4051
)
4152

4253
# Now define rules for the shared library
4354

44-
add_library(${AATM_MOD} SHARED ${AATM_SOURCES})
55+
add_library(${AATM_MOD} SHARED $<TARGET_OBJECTS:aatmobj>)
4556

4657
target_include_directories(${AATM_MOD} PUBLIC
4758
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
4859
$<INSTALL_INTERFACE:include>
49-
PRIVATE .
60+
PRIVATE src
5061
)
5162

5263
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
5364

54-
install(TARGETS ${AATM_MOD} DESTINATION ${CMAKE_INSTALL_LIBDIR})
65+
install(
66+
TARGETS
67+
${AATM_MOD}
68+
${AATM_STATIC}
69+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
70+
)

src/test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# Name of the internal static library
3-
set(AATM_LIB aatm_)
3+
set(AATM_LIB aatm_static)
44

55
#======================================================
66

0 commit comments

Comments
 (0)