-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
133 lines (112 loc) · 5.64 KB
/
CMakeLists.txt
File metadata and controls
133 lines (112 loc) · 5.64 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# --------------------- CMake configuration --------------------
cmake_minimum_required(VERSION 3.20)
set(CMAKE_OSX_DEPLOYMENT_TARGET "15.0" CACHE STRING "Minimum OS X deployment version")
project(PyMieSim LANGUAGES Fortran CXX)
# CMake settings
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Type of build")
# --------------------- CMake configuration --------------------
# --------------------- Set the output directory for libraries --------------------
set(LOCAL_CXX_DIR "${PROJECT_NAME}/cpp")
set(LOCAL_BIN_DIR "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/binary")
include_directories(${LOCAL_CXX_DIR})
# --------------------- Set the output directory for libraries --------------------
# --------------------- Platform-specific compiler and linker options --------------------
if(APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp" CACHE STRING "")
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "")
find_library(OpenMP_omp_LIBRARY omp HINTS $ENV{LIBOMP_PREFIX}/lib /opt/homebrew/opt/libomp/lib /usr/local/opt/libomp/lib)
if(OpenMP_omp_LIBRARY)
set(OpenMP_CXX_LIBRARIES "${OpenMP_omp_LIBRARY}" CACHE STRING "")
endif()
endif()
# Platform-specific settings for static linking
if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message("MinGW detected on Windows")
add_compile_options(-fopenmp)
add_link_options(-static -fopenmp -Wl,--whole-archive -lgomp -Wl,--no-whole-archive)
endif()
if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:/W4>
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>)
else()
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Wall>
$<$<COMPILE_LANGUAGE:CXX>:-Wextra>
$<$<COMPILE_LANGUAGE:CXX>:-pedantic-errors>
$<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-parameter>
)
endif()
# --------------------- Platform-specific compiler and linker options --------------------
# --------------------- Find dependencies and compile options --------------------
find_package(OpenMP REQUIRED COMPONENTS CXX)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
set(PYBIND11_FINDPYTHON ON)
# Compiler and linker options
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wno-unused-dummy-argument -Wno-compare-reals -Wno-do-subscript -Wno-intrinsic-shadow -Wmaybe-uninitialized")
endif()
# --------------------- Find dependencies and compile options --------------------
# ----------------- Package specific settings--------------------
# ----------------- Package specific settings--------------------
# ----------------- logging build configuration --------------------
message(STATUS "")
message(STATUS "==================== Build configuration ====================")
message(STATUS "Compiler information")
message(STATUS " C compiler : ${CMAKE_C_COMPILER}")
message(STATUS " C compiler ID : ${CMAKE_C_COMPILER_ID}")
message(STATUS " C compiler version : ${CMAKE_C_COMPILER_VERSION}")
message(STATUS " CXX compiler : ${CMAKE_CXX_COMPILER}")
message(STATUS " CXX compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " CXX compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS " Fortran compiler : ${CMAKE_Fortran_COMPILER}")
message(STATUS " Fortran ID : ${CMAKE_Fortran_COMPILER_ID}")
message(STATUS " Fortran version : ${CMAKE_Fortran_COMPILER_VERSION}")
message(STATUS "")
message(STATUS "OpenMP configuration")
message(STATUS " OpenMP flags : ${OpenMP_CXX_FLAGS}")
message(STATUS " OpenMP detected : ${OpenMP_FOUND}")
message(STATUS " OpenMP version : ${OpenMP_CXX_VERSION}")
message(STATUS "")
message(STATUS "Python configuration")
message(STATUS " Python executable : ${Python_EXECUTABLE}")
message(STATUS " Python version : ${PYBIND11_PYTHON_VERSION}")
message(STATUS " Python include dir : ${Python_INCLUDE_DIRS}")
message(STATUS " Python site packages : ${Python_SITELIB}")
message(STATUS "")
message(STATUS "PyMieSim integration")
message(STATUS " PyMieSim version : ${PYMIESIM_VERSION}")
message(STATUS " PyMieSim include dir : ${LOCAL_CXX_DIR}")
message(STATUS "")
message(STATUS "Install destination")
message(STATUS " Binary output path : ${LOCAL_BIN_DIR}")
message(STATUS "==============================================================")
message(STATUS "")
# ----------------- logging build configuration --------------------
# ----------------- collect subdirectories --------------------
add_subdirectory(PyMieSim/cpp/pint)
add_subdirectory(PyMieSim/cpp/coordinates)
add_subdirectory(PyMieSim/cpp/bessel_subroutine)
add_subdirectory(PyMieSim/cpp/material)
add_subdirectory(PyMieSim/cpp/polarization)
add_subdirectory(PyMieSim/cpp/mesh)
add_subdirectory(PyMieSim/cpp/single/mode_field)
add_subdirectory(PyMieSim/cpp/single/setup)
add_subdirectory(PyMieSim/cpp/single/source)
add_subdirectory(PyMieSim/cpp/single/scatterer)
add_subdirectory(PyMieSim/cpp/single/optical_interface)
add_subdirectory(PyMieSim/cpp/single/detector)
add_subdirectory(PyMieSim/cpp/experiment/polarization_set)
add_subdirectory(PyMieSim/cpp/experiment/source_set)
add_subdirectory(PyMieSim/cpp/experiment/material_set)
add_subdirectory(PyMieSim/cpp/experiment/scatterer_set)
add_subdirectory(PyMieSim/cpp/experiment/detector_set)
add_subdirectory(PyMieSim/cpp/experiment/setup)
# ----------------- collect subdirectories --------------------