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