| 1 | cmake_minimum_required ( VERSION 2.6 ) |
|---|
| 2 | |
|---|
| 3 | project( OpenLibraries ) |
|---|
| 4 | |
|---|
| 5 | set( VERSION_MAJOR 0 ) |
|---|
| 6 | set( VERSION_MINOR 5 ) |
|---|
| 7 | set( VERSION_PATCH 0 ) |
|---|
| 8 | set( PACKAGE "openlibraries-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) |
|---|
| 9 | set( VERSION_STRING "${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH}" ) |
|---|
| 10 | |
|---|
| 11 | # only required for non-umbrella builds |
|---|
| 12 | option( OPTION_UMBRELLA "enable umbrella build" OFF ) |
|---|
| 13 | if ( NOT OPTION_UMBRELLA ) |
|---|
| 14 | message( "defining plugin paths" ) |
|---|
| 15 | add_definitions( -DOPENIMAGELIB_PLUGINS="${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openimagelib/plugins" ) |
|---|
| 16 | add_definitions( -DOPENMEDIALIB_PLUGINS="${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openmedialib/plugins" ) |
|---|
| 17 | add_definitions( -DOPENASSETLIB_PLUGINS="${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openassetlib/plugins" ) |
|---|
| 18 | add_definitions( -DOPENOBJECTLIB_PLUGINS="${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openobjectlib/plugins" ) |
|---|
| 19 | add_definitions( -DOPENEFFECTSLIB_PLUGINS="${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openeffectslib/plugins" ) |
|---|
| 20 | endif( NOT OPTION_UMBRELLA ) |
|---|
| 21 | |
|---|
| 22 | # find optional and required modules |
|---|
| 23 | # check in the source directory |
|---|
| 24 | set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR} ) |
|---|
| 25 | |
|---|
| 26 | # boost |
|---|
| 27 | find_package( Boost COMPONENTS filesystem regex thread iostreams REQUIRED ) |
|---|
| 28 | if ( Boost_FOUND ) |
|---|
| 29 | message( "found boost: ${Boost_INCLUDE_DIR}" ) |
|---|
| 30 | include_directories( ${Boost_INCLUDE_DIR} ) |
|---|
| 31 | link_directories( ${Boost_LIBRARY_DIRS} ) |
|---|
| 32 | add_definitions( -DHAVE_BOOST_FILESYSTEM ) |
|---|
| 33 | endif ( Boost_FOUND ) |
|---|
| 34 | |
|---|
| 35 | # libxml |
|---|
| 36 | if ( NOT WIN32 ) |
|---|
| 37 | find_package( LibXml2 REQUIRED ) |
|---|
| 38 | if ( LIBXML2_FOUND ) |
|---|
| 39 | message( "found LibXml2: ${LIBXML2_INCLUDE_DIR}" ) |
|---|
| 40 | include_directories( ${LIBXML2_INCLUDE_DIR} ) |
|---|
| 41 | endif( LIBXML2_FOUND ) |
|---|
| 42 | endif( NOT WIN32 ) |
|---|
| 43 | |
|---|
| 44 | # opengl |
|---|
| 45 | find_package( OpenGL ) |
|---|
| 46 | if( OPENGL_FOUND ) |
|---|
| 47 | message( "found OpenGL: ${OPENGL_INCLUDE_DIR}" ) |
|---|
| 48 | include_directories( ${OPENGL_INCLUDE_DIR} ) |
|---|
| 49 | endif( OPENGL_FOUND ) |
|---|
| 50 | |
|---|
| 51 | # GLEW |
|---|
| 52 | find_package( GLEW ) |
|---|
| 53 | if ( GLEW_FOUND ) |
|---|
| 54 | message( "found GLEW: ${GLEW_INCLUDE_DIR}" ) |
|---|
| 55 | include_directories( ${GLEW_INCLUDE_DIR} ) |
|---|
| 56 | link_directories( ${GLEW_LIBRARY_DIR} ) |
|---|
| 57 | |
|---|
| 58 | set ( SHARE_PATH ${CMAKE_INSTALL_PREFIX}/share/${PACKAGE} ) |
|---|
| 59 | add_definitions( -DOPENOBJECTLIB_SHADERS="\\\"${SHARE_PATH}/shaders\\\"" ) |
|---|
| 60 | add_definitions( -DOPENEFFECTSLIB_SHADERS="\\\"${SHARE_PATH}/shaders\\\"" ) |
|---|
| 61 | add_definitions( -DHAVE_GL_GLEW_H ) |
|---|
| 62 | endif ( GLEW_FOUND ) |
|---|
| 63 | |
|---|
| 64 | # kill some warnings, add some windows specific defines |
|---|
| 65 | if ( WIN32 ) |
|---|
| 66 | set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4273 /wd4251 /wd4503" ) |
|---|
| 67 | set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t" ) |
|---|
| 68 | add_definitions( -DUNICODE ) |
|---|
| 69 | add_definitions( -D_CRT_SECURE_NO_DEPRECATE ) |
|---|
| 70 | |
|---|
| 71 | if( MSVC80 ) |
|---|
| 72 | set( COMPILER "vc80" ) |
|---|
| 73 | endif( MSVC80 ) |
|---|
| 74 | if( MSVC71 ) |
|---|
| 75 | set( COMPILER "vc71" ) |
|---|
| 76 | endif( MSVC71 ) |
|---|
| 77 | if ( CMAKE_BUILD_TYPE STREQUAL "Debug" ) |
|---|
| 78 | set( LIBRARY_IDENTIFIER "-${COMPILER}-d-${VERSION_STRING}" ) |
|---|
| 79 | else( CMAKE_BUILD_TYPE STREQUAL "Debug" ) |
|---|
| 80 | set( LIBRARY_IDENTIFIER "-${COMPILER}-r-${VERSION_STRING}" ) |
|---|
| 81 | endif( CMAKE_BUILD_TYPE STREQUAL "Debug" ) |
|---|
| 82 | endif( WIN32 ) |
|---|
| 83 | |
|---|
| 84 | IF ( UNIX ) |
|---|
| 85 | IF ( NOT APPLE ) |
|---|
| 86 | SET( CMAKE_SKIP_RPATH TRUE ) |
|---|
| 87 | ENDIF ( NOT APPLE ) |
|---|
| 88 | ENDIF ( UNIX ) |
|---|
| 89 | |
|---|
| 90 | # apple specific stuff |
|---|
| 91 | IF (APPLE) |
|---|
| 92 | FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation ) |
|---|
| 93 | ENDIF (APPLE) |
|---|
| 94 | |
|---|
| 95 | # Define options |
|---|
| 96 | |
|---|
| 97 | option ( WITH_PYTHON_EXTENSIONS "Compile the python extentions for OpenLibraries." TRUE ) |
|---|
| 98 | option ( WITH_OPENFX_PLUGIN "Compile the OpenFX plugin for openmedialib." FALSE ) |
|---|
| 99 | option ( WITH_OPENML "Compile the openmedialib." TRUE ) |
|---|
| 100 | option ( WITH_OPENIL "Compile the openimagelib." TRUE ) |
|---|
| 101 | option ( WITH_OPENAL "Compile the openassetlib." TRUE ) |
|---|
| 102 | option ( WITH_OPENFXL "Compile the openeffectslib." FALSE ) |
|---|
| 103 | option ( WITH_OPENOL "Compile the openobjectlib." TRUE ) |
|---|
| 104 | |
|---|
| 105 | if ( WITH_PYTHON_EXTENSIONS ) |
|---|
| 106 | # Python |
|---|
| 107 | find_package( PythonLibs ) |
|---|
| 108 | endif ( WITH_PYTHON_EXTENSIONS ) |
|---|
| 109 | |
|---|
| 110 | # Install .so files with execcuteable permissions |
|---|
| 111 | if ( NOT WIN32 ) |
|---|
| 112 | set ( CMAKE_INSTALL_SO_NO_EXE FALSE ) |
|---|
| 113 | endif ( NOT WIN32 ) |
|---|
| 114 | |
|---|
| 115 | add_subdirectory( src ) |
|---|
| 116 | |
|---|
| 117 | # function to convert a list (with their damned semicolons) |
|---|
| 118 | # to a space separated list |
|---|
| 119 | FUNCTION( CONVERT_LIST_TO_STRING _list _result ) |
|---|
| 120 | SET( result ) |
|---|
| 121 | LIST( LENGTH ${_list} _len ) |
|---|
| 122 | |
|---|
| 123 | # hack for brain dead range command... I mean, RANGE N yields N+1 numbers |
|---|
| 124 | MATH( EXPR len ${_len}-1 ) |
|---|
| 125 | FOREACH( index RANGE 0 ${len} ) |
|---|
| 126 | LIST( GET ${_list} ${index} li ) |
|---|
| 127 | SET( result "${result} ${li}" ) |
|---|
| 128 | ENDFOREACH( index RANGE 0 ${len} ) |
|---|
| 129 | |
|---|
| 130 | SET( ${_result} ${result} PARENT_SCOPE ) |
|---|
| 131 | ENDFUNCTION( CONVERT_LIST_TO_STRING ) |
|---|
| 132 | |
|---|
| 133 | # create openlibraries.pc for UNIX |
|---|
| 134 | if ( NOT WIN32 ) |
|---|
| 135 | list( APPEND EXTRA_LIBS_LIST -L${Boost_LIBRARY_DIRS} -lboost_filesystem ) |
|---|
| 136 | if ( GLEW_FOUND ) |
|---|
| 137 | list( APPEND EXTRA_LIBS_LIST -L${GLEW_LIBRARY_DIR} -lGLEW ) |
|---|
| 138 | list( APPEND EXTRA_LIBS_LIST -L${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}/openobjectlib/lib -lopenobjectlib_sg ) |
|---|
| 139 | endif ( GLEW_FOUND ) |
|---|
| 140 | |
|---|
| 141 | CONVERT_LIST_TO_STRING( EXTRA_LIBS_LIST EXTRA_LIBS ) |
|---|
| 142 | |
|---|
| 143 | list( APPEND EXTRA_INCLUDE_LIST -I${Boost_INCLUDE_DIRS} ) |
|---|
| 144 | if ( GLEW_FOUND ) |
|---|
| 145 | list( APPEND EXTRA_INCLUDE_LIST -I${GLEW_INCLUDE_DIR} ) |
|---|
| 146 | endif ( GLEW_FOUND ) |
|---|
| 147 | |
|---|
| 148 | CONVERT_LIST_TO_STRING( EXTRA_INCLUDE_LIST EXTRA_INCLUDES ) |
|---|
| 149 | |
|---|
| 150 | configure_file( openlibraries.pc.cmake ${CMAKE_SOURCE_DIR}/openlibraries.pc @ONLY ) |
|---|
| 151 | install( |
|---|
| 152 | FILES |
|---|
| 153 | ${CMAKE_SOURCE_DIR}/openlibraries.pc |
|---|
| 154 | DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/" ) |
|---|
| 155 | endif ( NOT WIN32 ) |
|---|