cmake: added FindOpenJPEG module.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 19 Jun 2011 07:46:24 +0000 (07:46 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 19 Jun 2011 07:46:24 +0000 (07:46 +0000)
CMakeLists.txt
build_files/cmake/Modules/FindOpenEXR.cmake
build_files/cmake/Modules/FindOpenJPEG.cmake [new file with mode: 0644]
build_files/cmake/Modules/FindPythonLibsUnix.cmake
build_files/cmake/Modules/FindSndFile.cmake
build_files/cmake/macros.cmake
source/blender/imbuf/CMakeLists.txt
source/blenderplayer/bad_level_call_stubs/CMakeLists.txt

index fed1785..c22266c 100644 (file)
@@ -267,6 +267,43 @@ if(UNIX AND NOT APPLE)
                set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}")
        endif()
 
+       find_package(JPEG REQUIRED)
+       find_package(PNG REQUIRED)
+       find_package(ZLIB REQUIRED)
+       find_package(Freetype REQUIRED)
+
+       if(WITH_PYTHON)
+               # No way to set py32. remove for now.
+               # find_package(PythonLibs)
+
+               # Use our own instead, since wothout py is such a rare case,
+               # require this package
+               find_package(PythonLibsUnix REQUIRED)
+       endif()
+
+
+       if(WITH_IMAGE_OPENEXR)
+               find_package(OpenEXR)  # our own module
+               if(NOT OPENEXR_FOUND)
+                       set(WITH_IMAGE_OPENEXR OFF)
+               endif()
+       endif()
+
+       if(WITH_IMAGE_OPENJPEG)
+               find_package(OpenJPEG)
+               if(NOT OPENJPEG_FOUND)
+                       set(WITH_IMAGE_OPENJPEG OFF)
+               endif()
+       endif()
+
+       if(WITH_IMAGE_TIFF)
+               find_package(TIFF)
+               if(NOT TIFF_FOUND)
+                       set(WITH_IMAGE_TIFF OFF)
+               endif()
+       endif()
+
+       # Audio IO
        if(WITH_OPENAL)
                find_package(OpenAL)
                if(NOT OPENAL_FOUND)
@@ -274,6 +311,18 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       if(WITH_SDL)
+               find_package(SDL)
+               mark_as_advanced(SDLMAIN_LIBRARY)
+               mark_as_advanced(SDL_INCLUDE_DIR)
+               mark_as_advanced(SDL_LIBRARY)
+               mark_as_advanced(SDL_LIBRARY_TEMP)
+               # unset(SDLMAIN_LIBRARY CACHE)
+               if(NOT SDL_FOUND)
+                       set(WITH_SDL OFF)
+               endif()
+       endif()
+
        if(WITH_JACK)
                set(JACK /usr)
                set(JACK_INCLUDE_DIRS ${JACK}/include/jack)
@@ -281,6 +330,7 @@ if(UNIX AND NOT APPLE)
                set(JACK_LIBPATH ${JACK}/lib)
        endif()
 
+       # Codecs
        if(WITH_CODEC_SNDFILE)
                find_package(SndFile)
                if(NOT SNDFILE_FOUND)
@@ -288,6 +338,16 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       if(WITH_CODEC_FFMPEG)
+               set(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
+               mark_as_advanced(FFMPEG)
+               set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
+               set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
+               mark_as_advanced(FFMPEG_LIBRARIES)
+               set(FFMPEG_LIBPATH ${FFMPEG}/lib)
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
+       endif()
+
        if(WITH_INTERNATIONAL)
                find_library(INTL_LIBRARY
                        NAMES intl
@@ -308,61 +368,6 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       find_package(Freetype REQUIRED)
-       # unset(FREETYPE_INCLUDE_DIRS CACHE) # cant use
-
-
-       if(WITH_PYTHON)
-               # No way to set py32. remove for now.
-               # find_package(PythonLibs)
-
-               # Use our own instead, since wothout py is such a rare case,
-               # require this package
-               find_package(PythonLibsUnix REQUIRED)
-       endif()
-
-       if(WITH_SDL)
-               find_package(SDL)
-               mark_as_advanced(SDLMAIN_LIBRARY)
-               mark_as_advanced(SDL_INCLUDE_DIR)
-               mark_as_advanced(SDL_LIBRARY)
-               mark_as_advanced(SDL_LIBRARY_TEMP)
-               # unset(SDLMAIN_LIBRARY CACHE)
-               if(NOT SDL_FOUND)
-                       set(WITH_SDL OFF)
-               endif()
-       endif()
-
-       if(WITH_IMAGE_OPENEXR)
-               find_package(OpenEXR)  # our own module
-               if(NOT OPENEXR_FOUND)
-                       set(WITH_IMAGE_OPENEXR OFF)
-               endif()
-       endif()
-
-       if(WITH_IMAGE_TIFF)
-               find_package(TIFF)
-               if(NOT TIFF_FOUND)
-                       set(WITH_IMAGE_TIFF OFF)
-               endif()
-       endif()
-
-       find_package(JPEG REQUIRED)
-
-       find_package(PNG REQUIRED)
-
-       find_package(ZLIB REQUIRED)
-
-       if(WITH_CODEC_FFMPEG)
-               set(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
-               mark_as_advanced(FFMPEG)
-               set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
-               set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
-               mark_as_advanced(FFMPEG_LIBRARIES)
-               set(FFMPEG_LIBPATH ${FFMPEG}/lib)
-               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
-       endif()
-
        if(WITH_FFTW3)
                set(FFTW3 /usr)
                set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
@@ -997,13 +1002,9 @@ endif()
 
 if(WITH_IMAGE_OPENJPEG)
        if(UNIX AND NOT APPLE)
-               set(OPENJPEG /usr)
-               set(OPENJPEG_INC ${OPENJPEG}/include)
-               set(OPENJPEG_LIB openjpeg)
-               set(OPENJPEG_LIBPATH ${OPENJPEG}/lib)
+               # dealt with above
        else()
-               set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
-               set(OPENJPEG_INC ${OPENJPEG})
+               set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
        endif()
 endif()
 
index 0d4610b..4dc2d5d 100644 (file)
@@ -63,7 +63,8 @@ SET(_openexr_LIBRARIES)
 FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
 
-  FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY NAMES ${COMPONENT}
+  FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY
+      NAMES ${COMPONENT}
       HINTS ${_openexr_SEARCH_DIRS}
       PATH_SUFFIXES lib64 lib
       )
diff --git a/build_files/cmake/Modules/FindOpenJPEG.cmake b/build_files/cmake/Modules/FindOpenJPEG.cmake
new file mode 100644 (file)
index 0000000..319d202
--- /dev/null
@@ -0,0 +1,67 @@
+# - Find OpenJPEG library
+# Find the native OpenJPEG includes and library
+# This module defines
+#  OPENJPEG_INCLUDE_DIRS, where to find openjpeg.h, Set when
+#                        OPENJPEG_INCLUDE_DIR is found.
+#  OPENJPEG_LIBRARIES, libraries to link against to use OpenJPEG.
+#  OPENJPEG_ROOT_DIR, The base directory to search for OpenJPEG.
+#                    This can also be an environment variable.
+#  OPENJPEG_FOUND, If false, do not try to use OpenJPEG.
+#
+# also defined, but not for general use are
+#  OPENJPEG_LIBRARY, where to find the OpenJPEG library.
+
+#=============================================================================
+# Copyright 2002-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# If OPENJPEG_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENJPEG_ROOT_DIR AND NOT $ENV{OPENJPEG_ROOT_DIR} STREQUAL "")
+  SET(OPENJPEG_ROOT_DIR $ENV{OPENJPEG_ROOT_DIR})
+ENDIF()
+
+SET(_openjpeg_SEARCH_DIRS
+  ${OPENJPEG_ROOT_DIR}
+  /usr/local
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+)
+
+FIND_PATH(OPENJPEG_INCLUDE_DIR openjpeg.h
+  HINTS
+    ${_openjpeg_SEARCH_DIRS}
+  PATH_SUFFIXES
+    include
+)
+
+FIND_LIBRARY(OPENJPEG_LIBRARY
+  NAMES "openjpeg"
+  HINTS ${_openjpeg_SEARCH_DIRS}
+  PATH_SUFFIXES lib64 lib
+  )
+
+# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenJPEG DEFAULT_MSG
+    OPENJPEG_LIBRARY OPENJPEG_INCLUDE_DIR)
+
+IF(OPENJPEG_FOUND)
+  SET(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
+  SET(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR})
+ENDIF(OPENJPEG_FOUND)
+
+MARK_AS_ADVANCED(
+  OPENJPEG_INCLUDE_DIR
+  OPENJPEG_LIBRARY
+)
index 07d95a5..5df12c5 100644 (file)
@@ -3,7 +3,6 @@
 #  PYTHON_VERSION
 #  PYTHON_INCLUDE_DIRS
 #  PYTHON_LIBRARIES
-#  PYTHON_LIBPATH
 #  PYTHON_LINKFLAGS
 #  PYTHON_ROOT_DIR, The base directory to search for Python.
 #                   This can also be an environment variable.
index e4c8d9f..5d0e1a5 100644 (file)
@@ -1,7 +1,7 @@
 # - Find SndFile library
 # Find the native SndFile includes and library
 # This module defines
-#  SNDFILE_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when
+#  SNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
 #                        SNDFILE_INCLUDE_DIR is found.
 #  SNDFILE_LIBRARIES, libraries to link against to use SndFile.
 #  SNDFILE_ROOT_DIR, The base directory to search for SndFile.
@@ -44,7 +44,8 @@ FIND_PATH(SNDFILE_INCLUDE_DIR sndfile.h
     include
 )
 
-FIND_LIBRARY(SNDFILE_LIBRARY NAMES "sndfile"
+FIND_LIBRARY(SNDFILE_LIBRARY
+  NAMES "sndfile"
   HINTS ${_sndfile_SEARCH_DIRS}
   PATH_SUFFIXES lib64 lib
   )
@@ -60,5 +61,7 @@ IF(SNDFILE_FOUND)
   SET(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
 ENDIF(SNDFILE_FOUND)
 
-MARK_AS_ADVANCED(SNDFILE_INCLUDE_DIR)
-MARK_AS_ADVANCED(SNDFILE_LIBRARY)
+MARK_AS_ADVANCED(
+  SNDFILE_INCLUDE_DIR
+  SNDFILE_LIBRARY
+)
index 5e2db8e..bb3761d 100644 (file)
@@ -266,7 +266,7 @@ macro(setup_liblinks
                endif()
        endif()
        if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
-               target_link_libraries(${target} ${OPENJPEG_LIB})
+               target_link_libraries(${target} ${OPENJPEG_LIBRARIES})
        endif()
        if(WITH_CODEC_FFMPEG)
                target_link_libraries(${target} ${FFMPEG_LIBRARIES})
index 812d5c0..14679b3 100644 (file)
@@ -119,7 +119,7 @@ if(WITH_IMAGE_TIFF)
 endif()
 
 if(WITH_IMAGE_OPENJPEG)
-       list(APPEND INC_SYS ${OPENJPEG_INC})
+       list(APPEND INC_SYS ${OPENJPEG_INCLUDE_DIRS})
        add_definitions(-DWITH_OPENJPEG)
 endif()
 
index 15c3b2a..80f3642 100644 (file)
@@ -56,8 +56,4 @@ if(WITH_GAMEENGINE)
        add_definitions(-DWITH_GAMEENGINE)
 endif()
 
-if(WITH_INTERNATIONAL)
-       add_definitions(-DWITH_FREETYPE2)
-endif()
-
 blender_add_lib_nolist(blenkernel_blc "${SRC}" "${INC}" "${INC_SYS}")