Skip to content

Commit 898c134

Browse files
committed
reorganize cmake option defaults, cmake flags, macros
cmake c and cxx flags include _CRT_SECURE_NO_WARNINGS to avoid a lot msdn warnings check_target macro is a helper to reduce number of lines in include/CMakeLists.txt
1 parent f53bfb0 commit 898c134

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

CMakeLists.txt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ endif()
99

1010
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/find_scripts;${CMAKE_MODULE_PATH}")
1111

12-
#TODO
13-
option(WITH_CAIRO "Build with cairo support ." ON)
12+
set(default_option_enabled ON)
1413
if(WIN32)
15-
option(WITH_X11 "Build with X11 support ." OFF)
16-
else()
17-
option(WITH_X11 "Build with X11 support ." ON)
14+
set(default_option_enabled OFF)
1815
endif()
16+
17+
option(WITH_CAIRO "Build with cairo support ." ON)
18+
option(WITH_X11 "Build with X11 support ." ${default_option_enabled})
1919
option(WITH_OPENGL "Build with opengl support ." ON)
2020
option(WITH_SQLITE "enable sqlite support" ON)
2121
option(WITH_POSTGRES "enable postgres support" OFF)
22-
option(WITH_NLS "enable sqlite support" ON)
22+
option(WITH_NLS "enable sqlite support" ${default_option_enabled})
2323
option(WITH_BZLIB "enable sqlite support" ON)
2424
option(WITH_BLAS "enable sqlite support" ON)
2525
option(WITH_LAPACK "enable sqlite support" ON)
26-
26+
option(WITH_LARGEFILES "enable largefile support" ${default_option_enabled})
2727
if(APPLE)
2828
if(POLICY CMP0042)
2929
cmake_policy(SET CMP0042 NEW)
@@ -50,11 +50,16 @@ set(BUILD_ARCH "x86_64")
5050
file(STRINGS "include/VERSION" GRASS_VERSION_STRINGS)
5151
list(LENGTH GRASS_VERSION_STRINGS GRASS_VERSION_FILE_LENGTH)
5252

53-
if(WIN32)
54-
set(CMAKE_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
55-
if(CMAKE_C_FLAGS)
56-
set(CMAKE_C_FLAGS "${GRASS_C_FLAGS} ${CMAKE_C_FLAGS}")
57-
endif()
53+
if(MSVC)
54+
set(GRASS_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
55+
if(CMAKE_C_FLAGS)
56+
set(CMAKE_C_FLAGS "${GRASS_C_FLAGS} ${CMAKE_C_FLAGS}")
57+
endif()
58+
59+
set(GRASS_CXX_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
60+
if(CMAKE_CXX_FLAGS)
61+
set(CMAKE_CXX_FLAGS "${GRASS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
62+
endif()
5863
endif()
5964

6065
if(GRASS_VERSION_FILE_LENGTH LESS 3 )
@@ -227,6 +232,14 @@ macro(build_program_in_subdir dir_name)
227232
endif()
228233
endmacro()
229234

235+
macro(check_target target_name have_define_var)
236+
set(${have_define_var} 0)
237+
if(TARGET ${target_name})
238+
message(STATUS "${target_name} package found. Setting ${have_define_var} to 1")
239+
set(${have_define_var} 1)
240+
endif()
241+
endmacro()
242+
230243
add_subdirectory(thirdparty)
231244

232245
include(cmake/scripts.cmake)

0 commit comments

Comments
 (0)