Skip to content

Commit e4d16a3

Browse files
committed
again build both static and shared lib; fixes #28
1 parent 30185a4 commit e4d16a3

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

numgrid/CMakeLists.txt

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_library(
2-
numgrid
3-
SHARED
2+
numgrid-objects
3+
OBJECT
44
AtomGrid.cpp
55
becke_partitioning.cpp
66
grid_radial.cpp
@@ -9,10 +9,14 @@ add_library(
99
lebedev/sphere_lebedev_rule.cpp
1010
)
1111

12-
add_dependencies(numgrid version)
12+
target_compile_options(
13+
numgrid-objects
14+
PRIVATE
15+
"-fPIC"
16+
)
1317

1418
target_include_directories(
15-
numgrid
19+
numgrid-objects
1620
PRIVATE
1721
${CMAKE_CURRENT_LIST_DIR}
1822
${CMAKE_CURRENT_LIST_DIR}/lebedev
@@ -21,6 +25,32 @@ target_include_directories(
2125
${CMAKE_CURRENT_BINARY_DIR}
2226
)
2327

28+
add_dependencies(numgrid-objects version)
29+
30+
add_library(
31+
numgrid-shared
32+
SHARED
33+
$<TARGET_OBJECTS:numgrid-objects>
34+
)
35+
36+
set_target_properties(
37+
numgrid-shared
38+
PROPERTIES
39+
OUTPUT_NAME "numgrid"
40+
)
41+
42+
add_library(
43+
numgrid-static
44+
STATIC
45+
$<TARGET_OBJECTS:numgrid-objects>
46+
)
47+
48+
set_target_properties(
49+
numgrid-static
50+
PROPERTIES
51+
OUTPUT_NAME "numgrid"
52+
)
53+
2454
if(ENABLE_FC_SUPPORT)
2555
add_library(
2656
numgrid_fortran_bindings
@@ -31,14 +61,14 @@ if(ENABLE_FC_SUPPORT)
3161
target_link_libraries(
3262
numgrid_fortran_bindings
3363
PRIVATE
34-
numgrid
64+
numgrid-objects
3565
)
3666
endif()
3767

3868
# generate numgrid_export.h
3969
include(GenerateExportHeader)
4070
generate_export_header(
41-
numgrid
71+
numgrid-shared
4272
BASE_NAME numgrid
4373
)
4474

@@ -48,15 +78,15 @@ file(
4878
)
4979

5080
set_target_properties(
51-
numgrid
81+
numgrid-shared
5282
PROPERTIES
5383
PUBLIC_HEADER "numgrid.h;${CMAKE_CURRENT_BINARY_DIR}/numgrid_export.h"
5484
RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/interface_file_names.cfg"
5585
)
5686

5787
install(
5888
TARGETS
59-
numgrid
89+
numgrid-shared
6090
LIBRARY
6191
DESTINATION numgrid/lib
6292
RUNTIME
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[configuration]
22
header_file_name = numgrid.h
3-
library_file_name = $<TARGET_FILE_NAME:numgrid>
3+
library_file_name = $<TARGET_FILE_NAME:numgrid-shared>

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target_include_directories(
3333
target_link_libraries(
3434
cpp_test
3535
PRIVATE
36-
numgrid
36+
numgrid-objects
3737
gtest_main
3838
)
3939

@@ -51,7 +51,7 @@ if(ENABLE_FC_SUPPORT)
5151
target_link_libraries(
5252
fortran_test
5353
numgrid_fortran_bindings
54-
numgrid
54+
numgrid-objects
5555
)
5656

5757
add_test(

0 commit comments

Comments
 (0)