-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
110 lines (89 loc) · 3.18 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
cmake_minimum_required(VERSION 3.10.0)
project(toastmm VERSION 0.9.2)
include(CTest)
enable_testing()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/dist)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS OFF)
set(TOAST_THREAD ON)
set(TOAST_FEATURE_RASTER2 FALSE)
set(TOAST_FEATURE_SINGLEPREC FALSE)
if(NOT BUILD_SHARED_LIBS)
add_compile_definitions(TOAST_STATIC)
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(TOAST_THREAD)
add_compile_definitions(TOAST_THREAD)
find_package(Threads REQUIRED)
# find_package(OpenMP REQUIRED)
endif()
# liblbfgs
set(LBFGS_USE_SSE ON)
set(LBFGS_lib_TARGET_NAME liblbfgs)
add_subdirectory(extern/liblbfgs)
# Toast architecture specific & rpath settings
#
# Windows
#
if(WIN32)
if(MSVC)
if(BUILD_SHARED_LIBS)
# Shared library builds are ecxeptionally noise due to various unresolved import/export
# issues, we quieten this for now to concentrate on the bad stuff
add_compile_options(/wd4244 /wd4996 /wd4267 /wd4251 /wd4910 /wd4661 /wd4305)
else()
# Static build is okay but unsafe warnings should be addressed
add_compile_options(/wd4244 /wd4996)
endif()
endif()
endif()
# MacOS and Linux
#
if(APPLE OR UNIX)
# Make builds quieter for development
add_compile_options(-Wno-comment -Wno-unused-variable -Wno-unused-result)
if(NOT APPLE)
add_compile_options(-Wno-format-truncation)
endif()
# Fix rpaths on install to point to the lib subdirectory and the same directory
# to support both normal installations (e.g. MATLAB) and Python packages
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib")
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
# Libraries
add_subdirectory(src/libmath)
add_subdirectory(src/libfe)
add_subdirectory(src/libraster)
add_subdirectory(src/libstoast)
add_subdirectory(src/libfdot)
# Executables
add_subdirectory(src/supertoast)
add_subdirectory(src/bintools)
# Interfaces
#
# We only build the MATLAB and Python interfaces under a static configuration, as this
# removes significant overhead in managing e.g., rpaths, and bundling of dynamic libraries.
#
if(BUILD_SHARED_LIBS)
message(STATUS "Shared library build select, MATLAB & Python interfaces will not be built")
else()
# MATLAB (mex) interface
add_subdirectory(src/matlab)
# Python interface
#
# Note that the python interface is simply an install target, which writes the source
# files into the distribution directory, compilation is performed using python tools
# in order to enable binary wheels to be built using, e.g., cibuildwheel. For a local
# build one may execute, e.g., `python setup.py bdist_wheel` in the output directory.
add_subdirectory(src/python)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)