Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit adfc124

Browse files
authored
Add CMake option to set shared or static build type (#335)
* Add CMake option to set shared/static build type
1 parent 17eb114 commit adfc124

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CMake/OpenAccHelper.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
# =============================================================================
66

77
if(CORENRN_ENABLE_GPU)
8-
# openacc needs to build static library in order to have global/routines
9-
# working. See https://www.pgroup.com/userforum/viewtopic.php?t=5350
10-
set(COMPILE_LIBRARY_TYPE "STATIC")
11-
128
# cuda unified memory support
139
if(CORENRN_ENABLE_CUDA_UNIFIED_MEMORY)
1410
add_definitions(-DUNIFIED_MEMORY)

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ option(CORENRN_ENABLE_LIKWID_PROFILING "Enable LIKWID instrumentation" OFF)
6969
option(CORENRN_ENABLE_CUDA_UNIFIED_MEMORY "Enable CUDA unified memory support" OFF)
7070
option(CORENRN_ENABLE_UNIT_TESTS "Enable unit tests execution" ON)
7171
option(CORENRN_ENABLE_GPU "Enable GPU support using OpenACC" OFF)
72+
option(CORENRN_ENABLE_SHARED "Enable shared library build" ON)
7273

7374
set(CORENRN_NMODL_DIR "" CACHE PATH "Path to nmodl source-to-source compiler installation")
7475
set(LIKWID_DIR "" CACHE PATH "Path to likwid performance analysis suite")
@@ -117,6 +118,14 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "PGI")
117118
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
118119
endif()
119120

121+
# OpenACC needs to build static library in order to have global/routines
122+
# working. See https://www.pgroup.com/userforum/viewtopic.php?t=5350
123+
if(CORENRN_ENABLE_SHARED AND NOT CORENRN_ENABLE_GPU)
124+
set(COMPILE_LIBRARY_TYPE "SHARED")
125+
else()
126+
set(COMPILE_LIBRARY_TYPE "STATIC")
127+
endif()
128+
120129
if(CORENRN_ENABLE_ISPC)
121130
enable_language(ISPC)
122131
add_definitions("-DISPC_INTEROP=1")
@@ -287,6 +296,7 @@ if(cmake_generator_tolower MATCHES "makefile")
287296
message(STATUS "--------------------+--------------------------------------------------------")
288297

289298
message(STATUS "COMPILE FLAGS | ${COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
299+
message(STATUS "Build Type | ${COMPILE_LIBRARY_TYPE}")
290300
message(STATUS "MPI | ${CORENRN_ENABLE_MPI}")
291301
if(CORENRN_ENABLE_MPI)
292302
message(STATUS " INC | ${MPI_C_INCLUDE_PATH}")

0 commit comments

Comments
 (0)