svn-gvsig-desktop / tags / v2_0_Build_1214 / libraries / libjni-potrace / CMakeLists.txt @ 46123
History | View | Annotate | Download (6.67 KB)
1 | 22706 | bsanchez | PROJECT(jpotrace) |
---|---|---|---|
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 | MESSAGE(STATUS "Platform:" ${platform_dir}) |
||
39 | |||
40 | SET(GVSIG_BINARIES_PATH "${CMAKE_SOURCE_DIR}/../binaries/${platform_dir}/raster/potrace") |
||
41 | |||
42 | SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") |
||
43 | FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib-dist) |
||
44 | #FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin-dist) |
||
45 | |||
46 | set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib-dist) |
||
47 | #set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin-dist) |
||
48 | #set(CMAKE_SKIP_RPATH TRUE) |
||
49 | IF(APPLE) |
||
50 | SET(CMAKE_INSTALL_NAME_DIR @executable_path/../Resources/NativeLibs CACHE STRING "Executable Path for MacOS X" FORCE) |
||
51 | MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_DIR) |
||
52 | ENDIF(APPLE) |
||
53 | |||
54 | |||
55 | SET(CMAKE_INSTALL_PREFIX ${GVSIG_BINARIES_PATH} CACHE STRING "Forcing install path" FORCE) |
||
56 | MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX) |
||
57 | |||
58 | # This is for an advanced option to give aggressive warnings |
||
59 | # under different compilers. If yours is not implemented, this option |
||
60 | # will not be made available. |
||
61 | IF(CMAKE_COMPILER_IS_GNUCXX) |
||
62 | # To be complete, we might also do GNUCC flags, |
||
63 | # but everything here is C++ code. |
||
64 | # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG |
||
65 | # returns too many hits. |
||
66 | # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another |
||
67 | # interesting C-specific flag. |
||
68 | # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create |
||
69 | # errors instead of warnings for certain issues, including superfluous |
||
70 | # semicolons and commas, and the use of long long. -fpermissive seems |
||
71 | # to be the workaround. |
||
72 | SET(AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive") |
||
73 | ELSE(CMAKE_COMPILER_IS_GNUCXX) |
||
74 | IF(MSVC) |
||
75 | # FIXME: What are good aggressive warning flags for Visual Studio? |
||
76 | # And do we need to further subcase this for different versions of VS? |
||
77 | # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005 |
||
78 | SET(AGGRESSIVE_WARNING_FLAGS "/Wall /W4") |
||
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 | SET(JPOTRACE_VERSION "0.0.1" CACHE STRING "JPOTRACE_VERSION") |
||
140 | |||
141 | FIND_PACKAGE(JNI) |
||
142 | FIND_PACKAGE(POTRACE) |
||
143 | |||
144 | link_directories(${LIBRARY_OUTPUT_PATH}) |
||
145 | |||
146 | add_subdirectory(src/main/native/jpotrace) |
||
147 | |||
148 | # This needs to be run very last so other parts of the scripts can take |
||
149 | # advantage of this. |
||
150 | IF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |
||
151 | 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") |
||
152 | ENDIF(NOT CONFIG_HAS_BEEN_RUN_BEFORE) |