Skip to content

Commit 8424009

Browse files
committed
CMakeLists.txt: Added library naming, resolves QuEST-Kit#351
1 parent b65b481 commit 8424009

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ endif()
4141
option(BUILD_SHARED_LIBS "Build shared library. Turned ON by default." ON)
4242
message(STATUS "Shared library is turned ${BUILD_SHARED_LIBS}. Set BUILD_SHARED_LIBS to modify.")
4343

44+
# Library naming
45+
set(LIB_NAME QuEST
46+
CACHE
47+
STRING
48+
"Change library name. LIB_NAME is QuEST by default."
49+
)
50+
message(STATUS "Library will be named lib${LIB_NAME}. Set LIB_NAME to modify.")
51+
52+
option(VERBOSE_LIB_NAME "Modify library name based on compilation configuration. Turned OFF by default." OFF)
53+
message(STATUS "Verbose library naming is turned ${VERBOSE_LIB_NAME}. Set VERBOSE_LIB_NAME to modify.")
54+
4455
# Precision
4556
set(FLOAT_PRECISION 2
4657
CACHE
@@ -54,6 +65,10 @@ set_property(CACHE FLOAT_PRECISION PROPERTY STRINGS
5465
)
5566
message(STATUS "Precision set to ${FLOAT_PRECISION}. Set FLOAT_PRECISION to modify.")
5667

68+
if (VERBOSE_LIB_NAME)
69+
string(CONCAT LIB_NAME ${LIB_NAME} "-fp${FLOAT_PRECISION}")
70+
endif()
71+
5772
# Testing
5873
option(
5974
ENABLE_TESTING
@@ -136,6 +151,9 @@ if (ENABLE_MULTITHREADING)
136151
OpenMP::OpenMP_CXX
137152
OpenMP::OpenMP_C
138153
)
154+
if (VERBOSE_LIB_NAME)
155+
string(CONCAT LIB_NAME ${LIB_NAME} "+mt")
156+
endif()
139157
else()
140158
target_compile_definitions(QuEST PUBLIC COMPILE_OPENMP=0)
141159
endif()
@@ -149,13 +167,19 @@ if (ENABLE_DISTRIBUTION)
149167
PUBLIC
150168
MPI::MPI_CXX
151169
)
170+
if (VERBOSE_LIB_NAME)
171+
string(CONCAT LIB_NAME ${LIB_NAME} "+mpi")
172+
endif()
152173
else()
153174
target_compile_definitions(QuEST PUBLIC COMPILE_MPI=0)
154175
endif()
155176

156177
if (ENABLE_GPU_ACCELERATION)
157178
enable_language(CUDA)
158179
target_compile_definitions(QuEST PUBLIC COMPILE_CUDA=1)
180+
if (VERBOSE_LIB_NAME)
181+
string(CONCAT LIB_NAME ${LIB_NAME} "+cuda")
182+
endif()
159183
else()
160184
target_compile_definitions(QuEST PUBLIC COMPILE_CUDA=0)
161185
endif()
@@ -170,6 +194,10 @@ if (NOT MSVC)
170194
target_link_libraries(QuEST PUBLIC ${MATH_LIBRARY})
171195
endif()
172196

197+
# Set output name
198+
set_target_properties(QuEST PROPERTIES OUTPUT_NAME ${LIB_NAME})
199+
200+
# Add source files
173201
add_subdirectory(quest)
174202

175203
## Examples

0 commit comments

Comments
 (0)