Skip to content

Commit

Permalink
reorganize cmake option defaults, cmake flags, macros
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rkanavath committed Dec 30, 2019
1 parent f53bfb0 commit 898c134
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ endif()

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

#TODO
option(WITH_CAIRO "Build with cairo support ." ON)
set(default_option_enabled ON)
if(WIN32)
option(WITH_X11 "Build with X11 support ." OFF)
else()
option(WITH_X11 "Build with X11 support ." ON)
set(default_option_enabled OFF)
endif()

option(WITH_CAIRO "Build with cairo support ." ON)
option(WITH_X11 "Build with X11 support ." ${default_option_enabled})
option(WITH_OPENGL "Build with opengl support ." ON)
option(WITH_SQLITE "enable sqlite support" ON)
option(WITH_POSTGRES "enable postgres support" OFF)
option(WITH_NLS "enable sqlite support" ON)
option(WITH_NLS "enable sqlite support" ${default_option_enabled})
option(WITH_BZLIB "enable sqlite support" ON)
option(WITH_BLAS "enable sqlite support" ON)
option(WITH_LAPACK "enable sqlite support" ON)

option(WITH_LARGEFILES "enable largefile support" ${default_option_enabled})
if(APPLE)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
Expand All @@ -50,11 +50,16 @@ set(BUILD_ARCH "x86_64")
file(STRINGS "include/VERSION" GRASS_VERSION_STRINGS)
list(LENGTH GRASS_VERSION_STRINGS GRASS_VERSION_FILE_LENGTH)

if(WIN32)
set(CMAKE_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${GRASS_C_FLAGS} ${CMAKE_C_FLAGS}")
endif()
if(MSVC)
set(GRASS_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${GRASS_C_FLAGS} ${CMAKE_C_FLAGS}")
endif()

set(GRASS_CXX_FLAGS "/D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${GRASS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
endif()
endif()

if(GRASS_VERSION_FILE_LENGTH LESS 3 )
Expand Down Expand Up @@ -227,6 +232,14 @@ macro(build_program_in_subdir dir_name)
endif()
endmacro()

macro(check_target target_name have_define_var)
set(${have_define_var} 0)
if(TARGET ${target_name})
message(STATUS "${target_name} package found. Setting ${have_define_var} to 1")
set(${have_define_var} 1)
endif()
endmacro()

add_subdirectory(thirdparty)

include(cmake/scripts.cmake)
Expand Down

0 comments on commit 898c134

Please sign in to comment.