svn-gvsig-desktop / tags / v2_0_Build_1210 / libraries / libjni-gdal / CMakeLists.txt @ 40799
History | View | Annotate | Download (6.8 KB)
1 |
project(jgdal) |
---|---|
2 |
|
3 |
|
4 |
# Looking for arch extension! |
5 |
SET(LIB_POSTFIX "32") |
6 |
IF(UNIX) |
7 |
IF(NOT APPLE) |
8 |
IF(CMAKE_SIZEOF_VOID_P MATCHES "8") |
9 |
SET(LIB_POSTFIX "64") |
10 |
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8") |
11 |
ENDIF(NOT APPLE) |
12 |
ELSE(UNIX) |
13 |
IF(CMAKE_SYSTEM_NAME MATCHES Windows) |
14 |
IF(CMAKE_CL_64) |
15 |
SET(LIB_POSTFIX "64") |
16 |
ENDIF(CMAKE_CL_64) |
17 |
ENDIF(CMAKE_SYSTEM_NAME MATCHES Windows) |
18 |
ENDIF(UNIX) |
19 |
|
20 |
SET(platform_dir) |
21 |
IF(WIN32) |
22 |
IF(NOT CYGWIN) |
23 |
SET(platform_dir "w${LIB_POSTFIX}") |
24 |
ENDIF(NOT CYGWIN) |
25 |
ENDIF(WIN32) |
26 |
IF(UNIX) |
27 |
IF(APPLE) |
28 |
SET(platform_dir "mac") |
29 |
ELSE(APPLE) |
30 |
SET(platform_dir "linux") |
31 |
ENDIF(APPLE) |
32 |
ENDIF(UNIX) |
33 |
|
34 |
IF(UNIX) |
35 |
SET(CMAKE_CXX_FLAGS_RELEASE "-O -DNDEBUG") |
36 |
SET(CMAKE_C_FLAGS_RELEASE "-O -DNDEBUG") |
37 |
ENDIF(UNIX) |
38 |
|
39 |
SET(GVSIG_BINARIES_PATH "${CMAKE_SOURCE_DIR}/../binaries/${platform_dir}/raster/gdal") |
40 |
|
41 |
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") |
42 |
FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib-dist) |
43 |
#FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin-dist) |
44 |
|
45 |
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib-dist) |
46 |
#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin-dist) |
47 |
#set(CMAKE_SKIP_RPATH TRUE) |
48 |
IF(APPLE) |
49 |
SET(CMAKE_INSTALL_NAME_DIR @executable_path/../Resources/NativeLibs CACHE STRING "Executable Path for MacOS X" FORCE) |
50 |
MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_DIR) |
51 |
ENDIF(APPLE) |
52 |
|
53 |
|
54 |
SET(CMAKE_INSTALL_PREFIX ${GVSIG_BINARIES_PATH} CACHE STRING "Forcing install path" FORCE) |
55 |
MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX) |
56 |
|
57 |
# This is for an advanced option to give aggressive warnings |
58 |
# under different compilers. If yours is not implemented, this option |
59 |
# will not be made available. |
60 |
IF(CMAKE_COMPILER_IS_GNUCXX) |
61 |
# To be complete, we might also do GNUCC flags, |
62 |
# but everything here is C++ code. |
63 |
# -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG |
64 |
# returns too many hits. |
65 |
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another |
66 |
# interesting C-specific flag. |
67 |
# Also, there is a bug in gcc 4.0. Under C++, -pedantic will create |
68 |
# errors instead of warnings for certain issues, including superfluous |
69 |
# semicolons and commas, and the use of long long. -fpermissive seems |
70 |
# to be the workaround. |
71 |
SET(AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive") |
72 |
ELSE(CMAKE_COMPILER_IS_GNUCXX) |
73 |
IF(MSVC) |
74 |
# FIXME: What are good aggressive warning flags for Visual Studio? |
75 |
# And do we need to further subcase this for different versions of VS? |
76 |
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005 |
77 |
SET(AGGRESSIVE_WARNING_FLAGS "/Wall /W4") |
78 |
|
79 |
|
80 |
ELSE(MSVC) |
81 |
# CMake lacks an elseif, so other non-gcc, non-VS compilers need |
82 |
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should |
83 |
# remain unset. |
84 |
ENDIF(MSVC) |
85 |
ENDIF(CMAKE_COMPILER_IS_GNUCXX) |
86 |
|
87 |
# This part is for the CMake menu option to toggle the warnings on/off. |
88 |
# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS. |
89 |
IF(AGGRESSIVE_WARNING_FLAGS) |
90 |
OPTION(USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" OFF) |
91 |
MARK_AS_ADVANCED(USE_AGGRESSIVE_WARNINGS) |
92 |
|
93 |
IF(USE_AGGRESSIVE_WARNINGS) |
94 |
IF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
95 |
SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "Old CXX flags") |
96 |
SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 1 CACHE INTERNAL "Old CXX flags was set") |
97 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
98 |
ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
99 |
ELSE(USE_AGGRESSIVE_WARNINGS) |
100 |
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was |
101 |
# set. The better way would be to parse the string and remove each |
102 |
# option explicitly. |
103 |
IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
104 |
SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
105 |
SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 0 CACHE INTERNAL "Old CXX flags was set") |
106 |
ENDIF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
107 |
ENDIF(USE_AGGRESSIVE_WARNINGS) |
108 |
ENDIF(AGGRESSIVE_WARNING_FLAGS) |
109 |
|
110 |
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 |
111 |
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. |
112 |
IF(APPLE) |
113 |
# These are just defaults/recommendations, but how we want to build |
114 |
# out of the box. But the user needs to be able to change these options. |
115 |
# So we must only set the values the first time CMake is run, or we |
116 |
# will overwrite any changes the user sets. |
117 |
# FORCE is used because the options are not reflected in the UI otherwise. |
118 |
# Seems like a good place to add version specific compiler flags too. |
119 |
IF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |
120 |
# This is really fragile, but CMake doesn't provide the OS system |
121 |
# version information we need. (Darwin versions can be changed |
122 |
# independently of OS X versions.) |
123 |
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. |
124 |
IF(EXISTS /Developer/SDKs/10.5.sdk) |
125 |
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) |
126 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
127 |
ELSE(EXISTS /Developer/SDKs/10.5.sdk) |
128 |
IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
129 |
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE) |
130 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
131 |
ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
132 |
# No Universal Binary support |
133 |
# Should break down further to set the -mmacosx-version-min, |
134 |
# but the SDK detection is too unreliable here. |
135 |
ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
136 |
ENDIF(EXISTS /Developer/SDKs/10.5.sdk) |
137 |
ENDIF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |
138 |
ENDIF(APPLE) |
139 |
|
140 |
|
141 |
SET(JGDAL_VERSION "0.6.3" CACHE STRING "JGDAL_VERSION") |
142 |
|
143 |
IF(WIN32) |
144 |
SET(HDF4) |
145 |
MARK_AS_ADVANCED(HDF4) |
146 |
SET(HDF5) |
147 |
MARK_AS_ADVANCED(HDF5) |
148 |
ENDIF(WIN32) |
149 |
|
150 |
find_package(JNI) |
151 |
find_package(GDAL) |
152 |
|
153 |
link_directories(${LIBRARY_OUTPUT_PATH}) |
154 |
|
155 |
add_subdirectory(src/main/native/jgdal) |
156 |
|
157 |
# This needs to be run very last so other parts of the scripts can take |
158 |
# advantage of this. |
159 |
IF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |
160 |
SET(CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") |
161 |
ENDIF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |
162 |
|
163 |
|