Statistics
| Revision:

root / trunk / libraries / libjni-ecw / CMakeLists.txt @ 20253

History | View | Annotate | Download (6.82 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
#IF(WIN32)
39
#	SET(CMAKE_CXX_FLAGS_RELEASE "/O /D N_DEBUG")
40
#	SET(CMAKE_C_FLAGS_RELEASE "/O /D N_DEBUG")
41
#ENDIF(WIN32)
42

    
43
SET(GVSIG_BINARIES_PATH "${CMAKE_SOURCE_DIR}/../binaries/${platform_dir}/raster/ecw")
44

    
45
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
46
FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib-dist)
47
#FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin-dist)
48

    
49
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib-dist)
50
#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin-dist)
51
#set(CMAKE_SKIP_RPATH TRUE)
52
IF(APPLE)
53
	SET(CMAKE_INSTALL_NAME_DIR @executable_path/../Resources/NativeLibs CACHE STRING "Executable Path for MacOS X" FORCE)
54
  	MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_DIR)
55
ENDIF(APPLE)
56

    
57

    
58
SET(CMAKE_INSTALL_PREFIX ${GVSIG_BINARIES_PATH} CACHE STRING "Forcing install path" FORCE)
59
MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
60

    
61
# This is for an advanced option to give aggressive warnings
62
# under different compilers. If yours is not implemented, this option
63
# will not be made available.
64
IF(CMAKE_COMPILER_IS_GNUCXX)
65
    # To be complete, we might also do GNUCC flags,
66
    # but everything here is C++ code.
67
    # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
68
    # returns too many hits.
69
    # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
70
    # interesting C-specific flag.
71
    # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
72
    # errors instead of warnings for certain issues, including superfluous
73
    # semicolons and commas, and the use of long long. -fpermissive seems
74
    # to be the workaround.
75
    SET(AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
76
ELSE(CMAKE_COMPILER_IS_GNUCXX)
77
    IF(MSVC)
78
        # FIXME: What are good aggressive warning flags for Visual Studio?
79
        # And do we need to further subcase this for different versions of VS?
80
        # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
81
        SET(AGGRESSIVE_WARNING_FLAGS "/Wall /W4")
82

    
83

    
84
    ELSE(MSVC)
85
        # CMake lacks an elseif, so other non-gcc, non-VS compilers need
86
        # to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
87
        # remain unset.
88
    ENDIF(MSVC)
89
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
90

    
91
# This part is for the CMake menu option to toggle the warnings on/off.
92
# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
93
IF(AGGRESSIVE_WARNING_FLAGS)
94
    OPTION(USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" OFF)
95
    MARK_AS_ADVANCED(USE_AGGRESSIVE_WARNINGS)
96

    
97
    IF(USE_AGGRESSIVE_WARNINGS)
98
        IF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
99
            SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "Old CXX flags")
100
            SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 1 CACHE INTERNAL "Old CXX flags was set")
101
            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
102
        ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
103
    ELSE(USE_AGGRESSIVE_WARNINGS)
104
        # FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
105
        # set. The better way would be to parse the string and remove each
106
        # option explicitly.
107
        IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
108
            SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
109
            SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 0 CACHE INTERNAL "Old CXX flags was set")
110
        ENDIF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
111
    ENDIF(USE_AGGRESSIVE_WARNINGS)
112
ENDIF(AGGRESSIVE_WARNING_FLAGS)
113

    
114
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
115
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
116
IF(APPLE)
117
    # These are just defaults/recommendations, but how we want to build
118
    # out of the box. But the user needs to be able to change these options.
119
    # So we must only set the values the first time CMake is run, or we
120
    # will overwrite any changes the user sets.
121
    # FORCE is used because the options are not reflected in the UI otherwise.
122
    # Seems like a good place to add version specific compiler flags too.
123
    IF(NOT CONFIG_HAS_BEEN_RUN_BEFORE)
124
        # This is really fragile, but CMake doesn't provide the OS system
125
        # version information we need. (Darwin versions can be changed
126
        # independently of OS X versions.)
127
        # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
128
        IF(EXISTS /Developer/SDKs/10.5.sdk)
129
            SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
130
            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)
131
        ELSE(EXISTS /Developer/SDKs/10.5.sdk)
132
            IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
133
                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
134
                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)
135
            ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
136
                # No Universal Binary support
137
                # Should break down further to set the -mmacosx-version-min,
138
                # but the SDK detection is too unreliable here.
139
            ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
140
        ENDIF(EXISTS /Developer/SDKs/10.5.sdk)
141
    ENDIF(NOT CONFIG_HAS_BEEN_RUN_BEFORE)
142
ENDIF(APPLE)
143

    
144

    
145
SET(JECW_VERSION "0.0.5" CACHE STRING "JECW_VERSION")
146

    
147
find_package(JNI) 
148
find_package(ECW) 
149

    
150
link_directories(${LIBRARY_OUTPUT_PATH})
151

    
152
add_subdirectory(src/main/native/jecw)
153

    
154
# This needs to be run very last so other parts of the scripts can take
155
# advantage of this.
156
IF(NOT CONFIG_HAS_BEEN_RUN_BEFORE)
157
    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")
158
ENDIF(NOT CONFIG_HAS_BEEN_RUN_BEFORE)
159

    
160