Skip to content

Commit c5596ae

Browse files
committed
[Project] Get lib name for each platform
1 parent d1cfad6 commit c5596ae

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

cubool/CMakeLists.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ if (CUBOOL_WITH_CUDA)
1313
message(STATUS "Add CUDA backend for GPGPU computations")
1414
endif()
1515

16+
set(TARGET_NAME cubool)
17+
set(TARGET_FILE_NAME)
18+
set(DEFINES_LIST)
19+
20+
# Platform checks
21+
if(APPLE)
22+
list(APPEND DEFINES_LIST CUBOOL_PLATFORM_MACOS)
23+
set(TARGET_FILE_NAME "lib${TARGET_NAME}.dylib")
24+
elseif(UNIX)
25+
list(APPEND DEFINES_LIST CUBOOL_PLATFORM_LINUX)
26+
set(TARGET_FILE_NAME "lib${TARGET_NAME}.so")
27+
elseif(WIN32)
28+
list(APPEND DEFINES_LIST CUBOOL_PLATFORM_WIN)
29+
set(TARGET_FILE_NAME "${TARGET_NAME}.dll")
30+
else()
31+
message(FATAL_ERROR "Platform not specified")
32+
endif()
33+
1634
# Library sources
1735
set(CUBOOL_SOURCES
1836
sources/core/config.hpp
@@ -27,8 +45,7 @@ set(CUBOOL_SOURCES
2745
sources/utils/exclusive_scan.hpp
2846
sources/utils/timer.hpp
2947
sources/utils/csr_utils.cpp
30-
sources/utils/csr_utils.hpp
31-
)
48+
sources/utils/csr_utils.hpp)
3249

3350
set(CUBOOL_C_API_SOURCES
3451
include/cubool/cubool.h
@@ -139,6 +156,11 @@ target_compile_options(cubool PRIVATE $<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUA
139156
set_target_properties(cubool PROPERTIES CXX_STANDARD 17)
140157
set_target_properties(cubool PROPERTIES CXX_STANDARD_REQUIRED ON)
141158

159+
# Platform defines
160+
foreach(DEFINE ${DEFINES_LIST})
161+
target_compile_definitions(cubool PUBLIC ${DEFINE})
162+
endforeach()
163+
142164
# Cuda specifics
143165
if (CUBOOL_WITH_CUDA)
144166
set_target_properties(cubool PROPERTIES CUDA_STANDARD 14)
@@ -171,14 +193,13 @@ endif()
171193

172194
# Copy cubool library after build if allowed
173195
if (CUBOOL_COPY_TO_PY_PACKAGE)
174-
# todo: Different platforms has specific naming conventions
175-
set(LIBRARY_FILE_NAME "libcubool.so")
196+
set(LIBRARY_FILE_NAME ${TARGET_FILE_NAME})
176197

177198
add_custom_command(
178199
TARGET cubool POST_BUILD
179200
COMMAND "${CMAKE_COMMAND}" -E
180201
copy
181202
"${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}"
182203
"${CMAKE_BINARY_DIR}/python/pycubool"
183-
COMMENT "Copy cubool compiled lib into python folder")
204+
COMMENT "Copy ${LIBRARY_FILE_NAME} compiled lib into python folder")
184205
endif()

0 commit comments

Comments
 (0)