-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
118 lines (102 loc) · 4.24 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
111
112
113
114
115
116
117
118
###############################################################################
# This file is part of GALARIO: #
# Gpu Accelerated Library for Analysing Radio Interferometer Observations #
# #
# Copyright (C) 2017-2020, Marco Tazzari, Frederik Beaujean, Leonardo Testi. #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the Lesser GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# For more details see the LICENSE file. #
# For documentation see https://mtazzari.github.io/galario/ #
###############################################################################
cmake_minimum_required(VERSION 3.0)
project(galario)
set(PACKAGE_VERSION "'1.2.2'")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# if inside a conda env, install everything in there
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND DEFINED ENV{CONDA_PREFIX})
# https://stackoverflow.com/questions/21437514/
set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}" CACHE PATH "Set the prefix based on conda environment" FORCE)
message(STATUS "Installing inside conda env at ${CMAKE_INSTALL_PREFIX}")
endif()
# ship extra findXXX.cmake in `cmake/`
# APPEND doesn't propagate variable to subdirectory
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# many more useful cmake module and scripts
# are downloaded into the build directory
include(LookUp-GreatCMakeCookOff)
###
# the optional packages
###
if(NOT DEFINED GALARIO_CHECK_CUDA)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(STATUS "Ignoring cuda on the mac by default. Force searching for cuda with `cmake -DGALARIO_CHECK_CUDA=1`")
set(GALARIO_CHECK_CUDA 0)
else()
set(GALARIO_CHECK_CUDA 1)
endif()
endif()
if(GALARIO_CHECK_CUDA)
find_package(CUDA)
#enable_language(CUDA)
endif()
# has to come before subdirectories are added
enable_testing()
# we can't use static libs with python
set(BUILD_SHARED_LIBS ON)
add_subdirectory(src)
###
# python not required but optional
###
set(BUILD_WRAPPER FALSE)
# Include the CMake script UseCython.cmake. This defines add_cython_module().
# Instruction for use can be found at the top of cmake/UseCython.cmake.
find_package(Cython)
if (CYTHON_EXECUTABLE)
include(UseCython)
endif()
if(PYTHONLIBS_FOUND AND CYTHON_FOUND)
# to avoid fatal error: numpy/arrayobject.h: No such file or directory
find_package(Numpy)
# should check NUMPY_FOUND but there is a bug in GreatCmakeCookoff
# https://github.com/UCL/GreatCMakeCookOff/issues/57
# upon calling `make` repeatedly, NUMPY_FOUND set to false
if (NUMPY_INCLUDE_DIRS)
set(BUILD_WRAPPER TRUE)
include_directories("${NUMPY_INCLUDE_DIRS}")
else ()
message(STATUS "NumPy not found")
endif()
endif()
if(BUILD_WRAPPER)
message(STATUS "Building the ${PROJECT_NAME} python wrapper")
add_subdirectory(python)
else()
message(STATUS "Skipping the ${PROJECT_NAME} python wrapper")
endif()
find_package(Sphinx)
if(SPHINX_FOUND)
add_subdirectory(docs)
else()
message(STATUS "Cannot build the documentation without sphinx")
endif()
###
# uninstall target
###
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)