cleanup header file and move to implementation
[openjpeg.git] / CMakeLists.txt
index 5f83362b7da6b44fe9e87be75c17b6955506a48c..68814d231f87fb16075c9f8cd0fde3e37234d9ff 100644 (file)
@@ -11,6 +11,9 @@ cmake_minimum_required(VERSION 2.8.2)
 
 if(COMMAND CMAKE_POLICY)
   cmake_policy(SET CMP0003 NEW)
+  if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
+    cmake_policy(SET CMP0042 NEW)
+  endif()
 endif()
 
 if(NOT OPENJPEG_NAMESPACE)
@@ -148,6 +151,7 @@ endif()
 
 if (APPLE)
        list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
+       option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
 endif()
 
 #-----------------------------------------------------------------------------
@@ -186,7 +190,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
   # For all builds, make sure openjpeg is std99 compliant:
   # set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
   # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
-  set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
+  SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
 endif()
 
 #-----------------------------------------------------------------------------
@@ -221,6 +225,20 @@ CHECK_INCLUDE_FILE("unistd.h"       HAVE_UNISTD_H)
 include(TestLargeFiles)
 OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
 
+include(CheckIncludeFiles)
+check_include_files(malloc.h HAVE_MALLOC_H)
+include(CheckSymbolExists)
+# aligned_alloc
+set(CMAKE_REQUIRED_FLAGS "-std=c11")
+check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
+unset(CMAKE_REQUIRED_FLAGS)
+# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
+check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
+# memalign
+check_symbol_exists(memalign malloc.h HAVE_MEMALIGN)
+# posix_memalign
+check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
+
 #-----------------------------------------------------------------------------
 # Build Library
 if(BUILD_JPIP_SERVER)