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