CMake: switch to GNUInstallDirs (#1424)
[openjpeg.git] / src / lib / openjpip / CMakeLists.txt
index e42e95fc2af2eb0933ad02a3535f86e45873375b..aace36d4d732f698b72897759866cee07cf3c40b 100644 (file)
@@ -1,6 +1,10 @@
 include_regular_expression("^.*$")
 
+add_definitions(-DUSE_JPIP)
+
 include_directories(
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
   ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
   ${FCGI_INCLUDE_DIRS}
   ${CURL_INCLUDE_DIRS}
@@ -32,6 +36,7 @@ set(OPENJPIP_SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
   ${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
   ${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
+  ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/opj_malloc.c
   )
 
 set(SERVER_SRCS
@@ -47,17 +52,31 @@ set(LOCAL_SRCS
   )
 
 # Build the library
-add_library(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
-target_link_libraries(openjpip_local ${OPENJPEG_LIBRARY_NAME})
+if(WIN32)
+  if(BUILD_SHARED_LIBS)
+    add_definitions(-DOPJ_EXPORTS)
+  else()
+    add_definitions(-DOPJ_STATIC)
+  endif()
+endif()
+add_library(openjpip ${OPENJPIP_SRCS} ${LOCAL_SRCS})
+set_target_properties(openjpip
+  PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
+if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
+  target_compile_options(openjpip PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
+target_link_libraries(openjpip ${OPENJPEG_LIBRARY_NAME})
 if(WIN32)
   # add Winsock on windows+mingw
-  target_link_libraries(openjpip_local ws2_32)
+  target_link_libraries(openjpip ws2_32)
 endif()
 
 # Install library
-install(TARGETS openjpip_local
+install(TARGETS openjpip
   EXPORT OpenJPEGTargets
-  DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Applications
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries
   )
 
 if(BUILD_JPIP_SERVER)
@@ -67,6 +86,6 @@ if(BUILD_JPIP_SERVER)
     PROPERTIES COMPILE_FLAGS "-DSERVER")
   install(TARGETS openjpip_server
     EXPORT OpenJPEGTargets
-    DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
+    DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries
     )
 endif()