Skip to content

Commit

Permalink
Pedantic tidy up of CMakeLists:
Browse files Browse the repository at this point in the history
Add Boost 1.44 and 1.45 to additional versions list (1.45 works fine, can't imagine 1.44 is incompatible)

Move the find OpenGL/OIIO stuff into OCIOMacros. Probably belongs in a Find___.cmake file

Try and find OIIO/OpenGL/etc, build applications if they are found

Components more consistently check if their requirements are met in the root CMakeLists.txt, rather than wrapping the components CMakeList in an if() statement. This makes it easy to see what components have requirements by looking at one file

Tidier and hopefully more helpful messages regarding applications and their requirements
  • Loading branch information
dbr committed Jan 30, 2011
1 parent 8d2571b commit f103709
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 338 deletions.
204 changes: 69 additions & 135 deletions CMakeLists.txt
@@ -1,4 +1,3 @@

project(OpenColorIO)
set(OCIO_VERSION_MAJOR 0)
set(OCIO_VERSION_MINOR 7)
Expand All @@ -8,16 +7,16 @@ set(OCIO_VERSION_PATCH 5)
# OCIO_VERSION value will be an accurate reflection of the underlying library version.
set(OCIO_VERSION "${OCIO_VERSION_MAJOR}.${OCIO_VERSION_MINOR}.${OCIO_VERSION_PATCH}")

if (NOT SOVERSION)
set (SOVERSION ${OCIO_VERSION_MAJOR} CACHE STRING "Set the SO version in the SO name of the output library")
endif ()
if (NOT ${SOVERSION} STREQUAL ${OCIO_VERSION_MAJOR})
set (OCIO_VERSION_MAJOR ${SOVERSION})
endif ()
if(NOT SOVERSION)
set(SOVERSION ${OCIO_VERSION_MAJOR} CACHE STRING "Set the SO version in the SO name of the output library")
endif()
if(NOT ${SOVERSION} STREQUAL ${OCIO_VERSION_MAJOR})
set(OCIO_VERSION_MAJOR ${SOVERSION})
endif()


cmake_minimum_required(VERSION 2.8)
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake )
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
if(NOT DEFINED CMAKE_FIRST_RUN)
SET(CMAKE_FIRST_RUN 1 CACHE INTERNAL "")
endif()
Expand Down Expand Up @@ -60,17 +59,21 @@ if(NOT OCIO_NAMESPACE)
FORCE)
endif(NOT OCIO_NAMESPACE)

OCIOFindPython()

# Enable a bunch of compiler warnings...
# http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wshadow -Wconversion -Wcast-qual -Wformat=2")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Weffc++ -Winline ")

# Find Python, used for (possibly) building pyglue, and now to
# construct the external project path
OCIOFindPython()

set(EXTDIST_ROOT ${CMAKE_BINARY_DIR}/ext/dist)
set(EXTDIST_BINPATH ${EXTDIST_ROOT}/bin)
set(EXTDIST_PYTHONPATH ${EXTDIST_ROOT}/lib/python${PYTHON_VERSION}/site-packages)
set(PYTHONPATH ${EXTDIST_PYTHONPATH}:$ENV{PYTHONPATH})
if(PYTHON_OK)
set(EXTDIST_PYTHONPATH ${EXTDIST_ROOT}/lib/python${PYTHON_VERSION}/site-packages)
set(PYTHONPATH ${EXTDIST_PYTHONPATH}:$ENV{PYTHONPATH})
endif()

if(CMAKE_FIRST_RUN)
message(STATUS "Setting Namespace to: ${OCIO_NAMESPACE}")
Expand Down Expand Up @@ -103,176 +106,107 @@ if(NOT MAKE_DOCS)
FORCE)
endif()

if(CMAKE_FIRST_RUN)
message(STATUS "Generate Documentation: ${MAKE_DOCS}")
endif()
messageonce("Generate Documentation: ${MAKE_DOCS}")

if(MAKE_DOCS)
add_subdirectory (docs)
if(PYTHON_OK)
add_subdirectory(docs)
else()
message(STATUS "Building the documentation requires Python, but locating Python failed: ${PYTHON_ERR}")
endif()
endif()

###############################################################################
### BOOST ###

set (Boost_ADDITIONAL_VERSIONS "1.43" "1.43.0" "1.42" "1.42.0"
"1.41" "1.41.0" "1.40" "1.40.0"
"1.39" "1.39.0" "1.38" "1.38.0"
"1.37" "1.37.0" "1.34.1" "1_34_1")
set (Boost_USE_STATIC_LIBS ON) # TODO: make this a option
set (Boost_USE_MULTITHREADED ON)
find_package (Boost 1.34 COMPONENTS program_options unit_test_framework)
set(Boost_ADDITIONAL_VERSIONS "1.45" "1.44" "1.43" "1.43.0" "1.42"
"1.42.0" "1.41" "1.41.0" "1.40"
"1.40.0" "1.39" "1.39.0" "1.38"
"1.38.0" "1.37" "1.37.0" "1.34.1"
"1_34_1")

set(Boost_USE_STATIC_LIBS ON) # TODO: make this a option
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.34 COMPONENTS program_options unit_test_framework)

###############################################################################
### SSE ###

option(USE_SSE "Set to OFF to disable SSE optimizations." ON)
if(USE_SSE)
if(CMAKE_FIRST_RUN)
message(STATUS "SSE Runtime: ENABLED")
endif()
messageonce("SSE Runtime: ENABLED")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
add_definitions("-DUSE_SSE")
else()
message(STATUS "SSE Runtime: DISABLED")
messageonce("SSE Runtime: DISABLED")
endif()

###############################################################################
### CORE ###

add_subdirectory (src/core)
add_subdirectory (src/core_tests)
add_subdirectory(src/core)
if(Boost_FOUND)
add_subdirectory(src/core_tests)
endif()

###############################################################################
### TEST BED ###

add_subdirectory (src/testbed)
add_subdirectory(src/testbed)

###############################################################################
### APPS ###

# Should we include OpenGL?
if(NOT USE_OPENGL)
set(USE_OPENGL NO CACHE BOOL
"Specify whether to build everything that requires OpenGL."
FORCE)
endif()
# Try to find OpenImageIO (OIIO) and OpenGL stuff
OCIOFindOpenImageIO()
OCIOFindOpenGL()

# ociocheck: verifies an OCIO config
add_subdirectory(src/apps/ociocheck)

if(CMAKE_FIRST_RUN AND NOT USE_OPENGL)
message(STATUS "USE_OPENGL not set. OpenGL example applications will not be built.")
# ocioconvert: performs file format conversion and colorspace
# transforms (uses OpenImageIO)
if(OIIO_FOUND)
add_subdirectory(src/apps/ocioconvert)
else()
messageonce("Not building ocioconvert. Requirement(s) found: OCIO:${OIIO_FOUND}")
endif()

if(USE_OPENGL)
if(APPLE)
INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
endif()

# Find OpenGL
find_package(OpenGL)
if(OPENGL_FOUND)
message(STATUS "Found OpenGL library ${OPENGL_LIBRARY}")
message(STATUS "Found OpenGL includes ${OPENGL_INCLUDE_DIR}")
else()
message (STATUS "OpenGL not found")
endif()

# Find GLUT
find_package(GLUT)
if(GLUT_FOUND)
message(STATUS "Found GLUT library ${GLUT_LIBRARY}")
else()
message (STATUS "GLUT not found")
endif()

# Find GLEW
set (GLEW_VERSION 1.5.1)
FIND_PATH( GLEW_INCLUDES GL/glew.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARIES
NAMES GLEW glew
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The GLEW library")
if (GLEW_INCLUDES AND GLEW_LIBRARIES)
set (GLEW_FOUND TRUE)
message(STATUS "Found GLEW library ${GLEW_LIBRARIES}")
message (STATUS "Found GLEW includes ${GLEW_INCLUDES}")
else ()
message (STATUS "GLEW not found")
endif ()
endif(USE_OPENGL)

if(CMAKE_FIRST_RUN AND NOT USE_OIIO)
message(STATUS "USE_OIIO not set. OpenImageIO example applications will not be built.")
# ociodisplay, displays color-transformed images (uses OpenImageIO,
# and OpenGL)
if(OPENGL_FOUND AND GLUT_FOUND AND GLEW_FOUND AND OIIO_FOUND)
add_subdirectory(src/apps/ociodisplay)
else()
messageonce("Not building ociodisplay. Requirement(s) found, OpenGL:${OPENGL_FOUND}, GLUT:${GLUT_FOUND}, GLEW:${GLEW_FOUND}, OIIO:${OIIO_FOUND}")
endif()

if(USE_OIIO)
if( OIIO_PATH )
message(STATUS "OIIO path excplicitly specified: ${OIIO_PATH}")
endif()
FIND_PATH( OIIO_INCLUDES OpenImageIO/version.h
${OIIO_PATH}/include/
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where OpenImageIO/version.h resides")
FIND_LIBRARY( OIIO_LIBRARIES
NAMES OIIO OpenImageIO
PATHS
${OIIO_PATH}/lib/
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The OIIO library")

if (OIIO_INCLUDES AND OIIO_LIBRARIES)
set (OIIO_FOUND TRUE)
message(STATUS "Found OIIO library ${OIIO_LIBRARIES}")
message (STATUS "Found OIIO includes ${OIIO_INCLUDES}")
else ()
message (STATUS "OIIO not found")
endif ()
endif(USE_OIIO)

add_subdirectory (src/apps/ociocheck)
add_subdirectory (src/apps/ocioconvert)
add_subdirectory (src/apps/ociodisplay)
# ocio2icc builds ICC profiles from an OCIO color transform (uses a
# bundled version of LittleCMS, and Boost's program_options)
if(Boost_FOUND)
add_subdirectory (src/apps/ocio2icc)
add_subdirectory(src/apps/ocio2icc)
else()
messageonce("Not building ocio2icc. Requirement(s) found, Boost:${BOOST_FOUND}")
endif()

###############################################################################
### NUKE ###

find_package( Nuke )
if( NUKE_FOUND )
if(CMAKE_FIRST_RUN)
message(STATUS " will build the Nuke plugins against ${Nuke_LIBRARY_DIR}")
endif()
add_subdirectory (src/nuke)
find_package(Nuke)
if(NUKE_FOUND)
messageonce("Will build the Nuke plugins against ${Nuke_LIBRARY_DIR}")
add_subdirectory(src/nuke)
else()
if(CMAKE_FIRST_RUN)
message(STATUS " if you want to build the Nuke plugins, add the flag -D NUKE_INSTALL_PATH=... or set the NDK_PATH environment variable")
endif()
messageonce("Not building Nuke plugins. Add the flag -D NUKE_INSTALL_PATH=... or set the NDK_PATH environment variable")
endif()

###############################################################################
### PYGLUE ###

add_subdirectory (src/pyglue)
if(PYTHON_OK)
add_subdirectory(src/pyglue)
else()
messageonce("Python bindings will not be built: ${PYTHON_ERR}")
endif()

###############################################################################
### CPACK ###
Expand Down
9 changes: 7 additions & 2 deletions docs/Setup.rst
Expand Up @@ -50,8 +50,8 @@ Enabling optional components
----------------------------

The OpenColourIO library is probably not all you want - the Python
libraries bindings and the Nuke nodes are only built if the
dependencies are found.
libraries bindings, the Nuke nodes and other included applications are only
built if their dependencies are found.

In the case of the Python bindings, the dependencies are the Python
headers for the version you wish to use. These may be picked up by
Expand Down Expand Up @@ -87,6 +87,11 @@ Python bindings for the same version of Python that Nuke uses
internally. For Nuke 6.0 and 6.1 this is Python 2.5, and for 6.2 it is
Python 2.6

The applications included with OCIO have various dependencies - to
determine these, look at the CMake output when first run::

-- Not building ocioconvert. Requirement(s) found: OCIO:FALSE

.. _environment-setup:

Environment setup
Expand Down

0 comments on commit f103709

Please sign in to comment.