File: CMakeLists.txt

package info (click to toggle)
mapserver 7.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,620 kB
  • sloc: ansic: 176,974; cpp: 58,161; python: 2,969; xml: 1,676; cs: 997; yacc: 856; lex: 766; java: 588; perl: 428; makefile: 374; sh: 184; tcl: 158; ruby: 55
file content (52 lines) | stat: -rw-r--r-- 2,397 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

find_package(JNI)
find_package(Java)
if(NOT JNI_INCLUDE_DIRS OR NOT Java_JAVAC_EXECUTABLE OR NOT Java_JAR_EXECUTABLE)
   message(SEND_ERROR "Could not find required Java componenents. Try setting the JAVA_HOME environment variable (required on e.g. Ubuntu)")
endif(NOT JNI_INCLUDE_DIRS OR NOT Java_JAVAC_EXECUTABLE OR NOT Java_JAR_EXECUTABLE)

include_directories(${JNI_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/mapscript/swiginc)
include_directories(${PROJECT_SOURCE_DIR}/mapscript/)
include_directories(${PROJECT_SOURCE_DIR}/mapscript/java)
set (CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/edu/umn/gis/mapscript")
set(CMAKE_SWIG_FLAGS -package edu.umn.gis.mapscript)

if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 3.7)
    swig_add_library(javamapscript TYPE MODULE LANGUAGE java SOURCES ../mapscript.i)
else ()
    swig_add_module(javamapscript java ../mapscript.i)
endif ()

# Java mapscript fails to build with -Werror=format-security

if(${CMAKE_C_FLAGS} MATCHES "-Werror=format-security")
  string(REPLACE "-Werror=format-security" "" TMP "${CMAKE_C_FLAGS}")
  set(CMAKE_C_FLAGS "${TMP}")
endif(${CMAKE_C_FLAGS} MATCHES "-Werror=format-security")

if(${CMAKE_CXX_FLAGS} MATCHES "-Werror=format-security")
  string(REPLACE "-Werror=format-security" "" TMP "${CMAKE_CXX_FLAGS}")
  set(CMAKE_CXX_FLAGS "${TMP}")
endif(${CMAKE_CXX_FLAGS} MATCHES "-Werror=format-security")

if(${CMAKE_CPP_FLAGS} MATCHES "-Werror=format-security")
  string(REPLACE "-Werror=format-security" "" TMP "${CMAKE_CPP_FLAGS}")
  set(CMAKE_CPP_FLAGS "${TMP}")
endif(${CMAKE_CPP_FLAGS} MATCHES "-Werror=format-security")

swig_link_libraries(javamapscript ${MAPSERVER_LIBMAPSERVER})

add_custom_command(TARGET javamapscript
                      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                      POST_BUILD
                      COMMAND ${Java_JAVAC_EXECUTABLE} edu/umn/gis/mapscript/*.java
                      COMMAND ${Java_JAR_EXECUTABLE} cf mapscript.jar edu/umn/gis/mapscript/*.class
                      COMMENT "Compiling java source files, creating mapscript.jar"
                      )

set(mapscript_files $<TARGET_FILE:${SWIG_MODULE_javamapscript_REAL_NAME}>)
install(FILES ${mapscript_files} DESTINATION lib/jni)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mapscript.jar DESTINATION share/java)