CMakeLists.txt 2.74 KB
Newer Older
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
cmake_minimum_required(VERSION 3.1)
project(pinkIndexer)

option(PINKINDEXER_BUILD_EXECUTABLE "Build the test executable for pinkIndexer" OFF)
 
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to 'Release' as none was specified.")
    set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
        "MinSizeRel" "RelWithDebInfo")
endif()
 
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
15
find_package(Eigen3 3.3.4 NO_MODULE)
16
find_package(OpenMP)
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
17

18
include_directories(include)
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
19

20
21
set(SOURCES src/Backprojection.cpp
			src/Chronometer.cpp
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
22
			src/ExperimentSettings.cpp
23
24
25
			src/Lattice.cpp
			src/PinkIndexer.cpp
			src/ReciprocalToRealProjection.cpp
26
			src/Refinement.cpp
27
			src/ReflectionsInRangeFinder.cpp
28
			src/SimpleDiffractionPatternPrediction.cpp
29
30
			src/SimpleProjection.cpp
			src/Sinogram.cpp
31
32

			src/adaptions/crystfel/ExperimentSettings.cpp
33
			src/adaptions/crystfel/indexerData.cpp
34
35
			src/adaptions/crystfel/PinkIndexer.cpp
			src/adaptions/crystfel/projectionData.cpp
36
			src/adaptions/crystfel/SimpleDiffractionPatternPrediction.cpp
37
			src/adaptions/crystfel/SimpleProjection.cpp
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
38
			src/adaptions/crystfel/lattice.cpp
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
39
40
41
42
43
44
)

set(SOURCES_test src/main.cpp
				 src/tests.cpp
)
 
45
 if(PINKINDEXER_BUILD_EXECUTABLE)
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
46
47
48
49
50
	add_executable(pinkIndexer ${SOURCES} ${SOURCES_test})
else(PINKINDEXER_BUILD_EXECUTABLE)
	add_library(pinkIndexer SHARED ${SOURCES})
endif(PINKINDEXER_BUILD_EXECUTABLE)

51
52
53
54
if(OpenMP_CXX_FOUND)
	target_link_libraries(pinkIndexer PUBLIC OpenMP::OpenMP_CXX)
endif(OpenMP_CXX_FOUND)

Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
if(EIGEN3_FOUND)
    target_link_libraries (pinkIndexer PUBLIC Eigen3::Eigen)
else()
    message("Eigen not found, using internal Eigen.")
    target_include_directories(pinkIndexer SYSTEM PUBLIC include/Eigen)
    
    install(
        DIRECTORY include/Eigen/
        DESTINATION include/eigen3
    )
endif()

# Test whether the compiler is Microsoft Visual C(++).
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  target_compile_options(pinkIndexer PUBLIC /W2 /wd4305 /wd4244 /wd4099)
else(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
71
72
  target_compile_options(pinkIndexer PUBLIC -Wall -pthread ) 
  set_target_properties(pinkIndexer PROPERTIES LINK_FLAGS "-pthread -Wl,--no-as-needed")
Yaroslav Gevorkov's avatar
Yaroslav Gevorkov committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
endif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
 

set_target_properties(pinkIndexer PROPERTIES 
    CXX_STANDARD 11
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS ON
)


install(TARGETS pinkIndexer 
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION lib
)

install(
    DIRECTORY include/
    DESTINATION include/pinkIndexer
    FILES_MATCHING
    PATTERN "*.h"
    PATTERN "Eigen/*" EXCLUDE
	PATTERN "Eigen" EXCLUDE
)