-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
52 lines (38 loc) · 1.43 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cmake_minimum_required(VERSION 3.7)
project(biot_savart)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
#set(CMAKE_SUPPRESS_REGENERATION true)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()
# Find OpenMP
find_package(OpenMP)
############################################################
# Create a library
############################################################
#Generate the shared library from the library sources
add_library(biot_savart_shared SHARED biot_savart.cpp)
set_target_properties(biot_savart_shared PROPERTIES OUTPUT_NAME biot_savart)
if(OpenMP_CXX_FOUND) # Check if OpenMP was successfully found for C++
target_link_libraries(biot_savart_shared OpenMP::OpenMP_CXX)
message(STATUS "OpenMP enabled for biot_savart_shared")
endif()
if (UNIX)
target_link_libraries(biot_savart_shared pthread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64" )
install(TARGETS biot_savart_shared LIBRARY DESTINATION lib)
endif()
if (WIN32)
add_compile_definitions(__EXPORT_CLASS_BIOTSAVART__)
endif()
find_package(Matlab)
if(Matlab_FOUND)
matlab_add_mex(NAME biot_savart SRC biot_savart.cpp R2018a)
endif()