-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
62 lines (50 loc) · 2.1 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
51
52
53
54
55
56
57
58
59
60
61
cmake_minimum_required(VERSION 3.9)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
project(uvlm)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
file(GLOB SOURCES src/cpp_interface.cpp)
include_directories(include)
add_library(uvlm SHARED ${SOURCES})
set_property(TARGET uvlm PROPERTY CXX_STANDARD 14)
if(CMAKE_BUILD_TYPE STREQUAL Release)
find_package(BLAS)
set(BUILD_SHARED_LIBS ON)
find_package(MKL)
if(NOT MKL_FOUND)
find_package(LAPACK REQUIRED)
target_link_libraries(uvlm PUBLIC ${LAPACK_LIBRARIES})
else()
include_directories(${MKL_INCLUDE_DIR})
target_link_libraries(uvlm PUBLIC ${MKL_LIBRARIES})
endif()
endif()
find_package(Eigen3 REQUIRED)
target_link_libraries(uvlm PUBLIC Eigen3::Eigen)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(uvlm PUBLIC OpenMP::OpenMP_CXX)
endif()
find_package(Eigen3 REQUIRED)
target_link_libraries(uvlm PUBLIC Eigen3::Eigen)
# For all compilers
target_compile_options(uvlm PUBLIC $<$<CONFIG:RELEASE>: -fomit-frame-pointer -ffast-math>)
# Dodgy thing for MacOS Catalina with anyting other than CLANG++
# Apple has removed the /usr/include dir in the folder structure.
# So compilers that are not the original Clang (AppleClang in CMAKE)
# do not work without this line
if(APPLE)
if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS "19.0.0")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
message(FATAL_ERROR "Intel icpc compiler with MacOS Catalina does not work properly as I am writing this. If you think this is wrong (or outdated), please file an issue in github.com/imperialcollegelondon/sharpy. For now, try another C++ compiler, like g++ or clang")
endif()
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
target_compile_options(uvlm PUBLIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk)
endif()
endif()
endif()
# Add custom debug flags
target_compile_options(uvlm PUBLIC $<$<CONFIG:DEBUG>: -Wall>)
install(TARGETS uvlm
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/lib)