Silenced all warnings.
[cmake-gdal:gdal-svn.git] / CMakeLists.txt
1 project(GDAL)
2 cmake_minimum_required(VERSION 2.8.2)
3
4 # GDAL CMake modules
5 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
6 set(CMAKE_COLOR_MAKEFILE ON)
7
8 include(GdalUtilities)
9
10 # GDAL version information
11
12 # Global vars.
13 set(INSTALL_HEADERS)
14
15 # Generate C/C++ configuration for GDAL
16 include(GdalConfig)
17
18 # Find GDAL dependencies
19 set   ( GDAL_WITH_zlib "Using ZLIB" ON )
20 option( GDAL_USE_EXTERNAL_zlib "Using external ZLIB" OFF )
21
22 set(GDAL_DEPENDS_LIBRARIES)
23
24 include(GdalDependencies)
25
26 # Build GDAL core modules
27 include(GdalAddModule)
28
29 set(GDAL_ALL_MODULES port gcore frmts alg ogr)
30
31 foreach(module ${GDAL_ALL_MODULES})
32   add_subdirectory(${module})
33 endforeach(module)
34
35 # Build main GDAL/OGR library target
36 option( BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON )
37
38 # Silence useless warnings.
39 if(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
40   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
41   add_definitions(-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
42 endif(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
43
44 # Silence all warnings.
45 if(UNIX)
46   add_definitions(-w)
47 endif(UNIX)
48 if(WIN32)
49   add_definitions(/w)
50 endif(WIN32)
51
52 # Collect sources of core modules
53 gdal_collect_sources("${GDAL_MODULES}" GDAL_LIBRARY_SOURCES)
54
55 set(GDAL_LIBRARY_SOURCES ${GDAL_LIBRARY_SOURCES}
56   ${CMAKE_CURRENT_SOURCE_DIR}/frmts/gdalallregister.cpp)
57
58 string(TOLOWER ${PROJECT_NAME} GDAL_LIBRARY_TARGET)
59
60 include_directories(
61   ${CMAKE_BINARY_DIR}/port
62   ${CMAKE_SOURCE_DIR}/port
63   ${CMAKE_SOURCE_DIR}/ogr
64   ${CMAKE_SOURCE_DIR}/gcore
65   ${GDAL_FRMTS_INCLUDE}
66   ${GDAL_ALG_INCLUDE}
67   ${GDAL_OGR_INCLUDE}
68 )
69
70 # UNIX requires linking with dl.
71 if(HAVE_LIBDL AND BUILD_SHARED_LIBS)
72   set(GDAL_DEPENDS_LIBRARIES ${GDAL_DEPENDS_LIBRARIES} dl)
73 endif(HAVE_LIBDL AND BUILD_SHARED_LIBS)
74
75 add_library(
76   ${GDAL_LIBRARY_TARGET}
77   ${GDAL_LIBRARY_SOURCES}
78   ${GDAL_FRMTS_SRC}
79   ${GDAL_ALG_SRC}
80   ${GDAL_OGR_SRC})
81
82 target_link_libraries(
83   ${GDAL_LIBRARY_TARGET}
84   ${GDAL_DEPENDS_LIBRARIES})
85
86 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin
87     CACHE PATH
88     "Single directory for all libraries.")
89
90 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin
91     CACHE PATH
92     "Single directory for all executables.")
93
94 install(TARGETS gdal
95   RUNTIME DESTINATION bin COMPONENT RuntimeLibraries
96   LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
97   ARCHIVE DESTINATION lib COMPONENT Development)
98
99 install(FILES ${INSTALL_HEADERS} DESTINATION include/ COMPONENT Development)
100
101 add_subdirectory(apps)