-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
97 lines (95 loc) · 4.26 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
#================================================================================
#
# Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo.
#
# This file is part of Commander3.
#
# Commander3 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Commander3 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Commander3. If not, see <https://www.gnu.org/licenses/>.
#
#================================================================================
# Ensure out-of-source build
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"\n-------------------------------------------------------------------"
"\n IN-SOURCE BUILDS ARE NOT ALLOWED!"
"\nTo sucessfully run CMake configuration, please, do the following:"
"\n1. Delete the CMakeCache.txt file and the CMakeFiles directory"
" created inside current (root) directory. For instance, on Linux do: "
"\n $ rm -r CMakeCache.txt CMakeFiles/"
"\n2. Create new directory (any name will do, but usually it is called build)"
" and re-run CMake configuration from it. For example, on Linux do:"
"\n $ mkdir build && cd build"
"\n $ cmake [CMake variable 1] [...] [CMake variable n] .."
"\n3. Run compilation command to install Commander3, e.g.: "
"\n $ cmake --build . --target install -j n"
"\n where n is the number of processors to utilize."
"\nFor more information, please refer to official documentation: "
"\n https://docs.beyondplanck.science"
"\nIn case you have any questions, feel free to post them on our forum:"
"\n https://forums.beyondplanck.science/"
"\n-------------------------------------------------------------------"
)
endif()
# Just a short message to signify start of configuration script
message(STATUS "===============================================================")
message(STATUS "Welcome to automatic Commander3 installer!")
message(STATUS "Issued under: GNU GPLv3 license")
message(STATUS "Official repo: https://github.com/Cosmoglobe/Commander")
message(STATUS "Documentation: https://cosmoglobe.github.io/Commander/#/")
message(STATUS "Forum: https://forums.beyondplanck.science/")
message(STATUS "===============================================================")
message(STATUS "Scanning your system. Please, wait a moment...")
# The necessary minimum to set-up cmake-based project
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(Commander3
DESCRIPTION "Complete installer for Commander 3."
VERSION 1.3.0
LANGUAGES Fortran CXX C
HOMEPAGE_URL "https://github.com/Cosmoglobe/Commander"
)
# Looking for python
find_package(Python REQUIRED COMPONENTS Interpreter)
# Including native cmake commands
include(CMakePrintHelpers)
include(CMakeDependentOption)
# Enables content population at configure time
#include(FetchContent)
# Including external project routines to enable superbuild pattern
include(ExternalProject)
# Including useful macro to operate with project options
include(CMakeDependentOption)
# Verify that Fortran and CXX compilers can properly talk to each other
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
# Check if given fortran source compiles
include(CheckFortranSourceCompiles)
# The -fPIC flag
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# The -flto
# Adding project modules dir (with .cmake extension)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${CMAKE_SOURCE_DIR}/cmake/modules"
"${CMAKE_SOURCE_DIR}/cmake/compilers"
"${CMAKE_SOURCE_DIR}/cmake/projects"
"${CMAKE_SOURCE_DIR}/cmake/third_party/cfitsio/cmake"
"${CMAKE_SOURCE_DIR}/cmake/third_party/curl/CMake"
)
# Including custom cmake modules
include(main)
# Adding commander3 source files
# Note: I have added commander.cmake as an "independent" project
# so there is no need for other cmake lists. Advantage of this
# approach is that everything located in the same folder (cmake)
#add_subdirectory(commander3)