-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·45 lines (37 loc) · 1.07 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
cmake_minimum_required(VERSION 3.16)
# XXX: undocumented
# https://stackoverflow.com/a/10306476/16079666
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(MELFP)
# for tail recursion
if(MSVC)
add_compile_options(/O2)
else()
add_compile_options(-O3)
endif()
file(GLOB src *.c *.h)
add_executable(melfp ${src})
if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
# for task
# avoid error C7660: 'task': requires '-openmp:llvm' command line option(s)
set(OpenMP_RUNTIME_MSVC "llvm")
endif()
find_package(OpenMP REQUIRED)
if(OpenMP_C_FOUND)
target_link_libraries(melfp PUBLIC OpenMP::OpenMP_C)
if(OpenMP_FOUND AND MSVC AND CMAKE_VERSION VERSION_LESS "3.30")
# CMake < 3.30 doesn't support OpenMP_RUNTIME_MSVC
# for task
add_compile_options(-openmp:llvm)
endif()
endif()
find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(melfp PUBLIC ${MATH_LIBRARY})
endif()
find_package(GDAL REQUIRED)
if(GDAL_FOUND)
target_link_libraries(melfp PUBLIC ${GDAL_LIBRARY})
target_include_directories(melfp PUBLIC ${GDAL_INCLUDE_DIR})
endif()