-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
65 lines (57 loc) · 1.98 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
cmake_minimum_required(VERSION 3.13)
project(makevalid C)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_C_STANDARD 11)
add_executable(
makevalid
src/main.c
src/config.c
src/config.h)
if (GEOS_DIR)
message(STATUS "Trying user-specified GEOS installation at ${GEOS_DIR}")
find_path(GEOS_INCLUDE_DIR geos_c.h
PATHS ${GEOS_DIR}/include
NO_DEFAULT_PATH)
find_library(GEOS_C_LIB geos_c
PATHS ${GEOS_DIR}/lib
NO_DEFAULT_PATH)
find_path(GEOS_CONFIG geos-config
PATHS ${GEOS_DIR}/bin
NO_DEFAULT_PATH)
else(GEOS_DIR)
find_path(GEOS_INCLUDE_DIR geos_c.h
PATHS
${CMAKE_INSTALL_PREFIX}/include
/usr/include
/usr/local/include)
find_library(GEOS_C_LIB NAMES geos_c
PATHS
${CMAKE_INSTALL_PREFIX}/lib
/usr/lib64
/usr/lib
/usr/local/lib)
find_path(GEOS_CONFIG geos-config
PATHS
/usr/bin
/usr/local/bin)
endif(GEOS_DIR)
if( GEOS_C_LIB AND GEOS_INCLUDE_DIR )
message( STATUS "Found GEOS..." )
else( GEOS_C_LIB AND GEOS_INCLUDE_DIR )
message( FATAL_ERROR "Could not find GEOS" )
endif( GEOS_C_LIB AND GEOS_INCLUDE_DIR )
message( STATUS "GEOS_INCLUDE_DIR=${GEOS_INCLUDE_DIR}" )
message( STATUS "GEOS_LIBRARY=${GEOS_C_LIB}" )
# Check GEOS version to ensure >= 3.8
if (GEOS_CONFIG)
message(STATUS "Found geos-config at ${GEOS_CONFIG}")
execute_process(COMMAND ${GEOS_CONFIG}/geos-config --version OUTPUT_VARIABLE GEOS_VERSION)
message(STATUS "GEOS Version: ${GEOS_VERSION}")
else (GEOS_CONFIG)
message(FATAL_ERROR "Could not find geos-config to check version")
endif(GEOS_CONFIG)
if (GEOS_VERSION STRLESS_EQUAL 3.8)
message(FATAL_ERROR "Makevalid requires GEOS >= 3.8")
endif(GEOS_VERSION STRLESS_EQUAL 3.8)
target_link_libraries(makevalid ${GEOS_C_LIB})
target_include_directories(makevalid PUBLIC ${GEOS_INCLUDE_DIR})