diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-06 12:51:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-06 12:57:32 +0300 |
commit | 40f237675f8627aefd1d5f46841ce03faf7b52e2 (patch) | |
tree | 7cd7d38b115c2f8c6f7ea230fa825ff6973df6ac /CMakeLists.txt | |
parent | 580bb2621330bdc8d99a92ce8be1856053c5b05d (diff) |
Some tweaks to support upcoming OSL-1.6
Doesn't mean we're 100% ready for the transition, but need to start somewhere
anyway. Changes:
- OSL is no longer supporting cpp and requires usage of Boost Wave.
So now Wave component of Boost is optionally demanded when looking for the
Boost libraries if OSL is enabled.
Only did this for Linux, MSVC seems already using Wave. Not sure about OSX.
- Because of the same reason OSL should be moved prior Boost for linker.
- Whole archive trick makes it so linking fails with duplicated symbols, so
removed it for the new OSL. Didn't see issues with this so far.
- Added some code to check OSL version on Linux. Would need to move all that
to FindOpenShadingLanguage.cmake which we can get from Cycles standalone
repository.
So in theory no affect on current stup would be made at all.
- Added some tweaks to buildbot files. It now seems to be happy with the new
OSL libraries, but again, those tweaks are not in action yet.
All this was tested on Linux only. Win/OSX might still need some tweaks to
support new OSL.
P.S. This doesn't mean we're pushing OSL update yet, just making some
preliminary tweaks to avoid entropy of PITA when we'll actually want to
switch.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 99357507cbb..15356e3445c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -926,6 +926,44 @@ if(UNIX AND NOT APPLE) endif() endif() + if(WITH_CYCLES_OSL) + set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") + + message(STATUS "CYCLES_OSL = ${CYCLES_OSL}") + + # TODO(sergey): Move to dedicated FindOpenShadingLanguage.cmake + find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) + find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) + find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) + if(EXISTS ${OSL_INCLUDE_DIR}) + file(STRINGS "${OSL_INCLUDE_DIR}/OSL/oslversion.h" OSL_LIBRARY_VERSION_MAJOR + REGEX "^[ \t]*#define[ \t]+OSL_LIBRARY_VERSION_MAJOR[ \t]+[0-9]+.*$") + file(STRINGS "${OSL_INCLUDE_DIR}/OSL/oslversion.h" OSL_LIBRARY_VERSION_MINOR + REGEX "^[ \t]*#define[ \t]+OSL_LIBRARY_VERSION_MINOR[ \t]+[0-9]+.*$") + string(REGEX REPLACE ".*#define[ \t]+OSL_LIBRARY_VERSION_MAJOR[ \t]+([.0-9]+).*" + "\\1" OSL_LIBRARY_VERSION_MAJOR ${OSL_LIBRARY_VERSION_MAJOR}) + string(REGEX REPLACE ".*#define[ \t]+OSL_LIBRARY_VERSION_MINOR[ \t]+([.0-9]+).*" + "\\1" OSL_LIBRARY_VERSION_MINOR ${OSL_LIBRARY_VERSION_MINOR}) + endif() + + if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6") + # Note: --whole-archive is needed to force loading of all symbols in liboslexec, + # otherwise LLVM is missing the osl_allocate_closure_component function + list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY}) + else() + list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) + endif() + + if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) + set(OSL_FOUND TRUE) + else() + message(STATUS "OSL not found") + set(WITH_CYCLES_OSL OFF) + endif() + endif() + if(WITH_BOOST) # uses in build instructions to override include and library variables if(NOT BOOST_CUSTOM) @@ -934,6 +972,12 @@ if(UNIX AND NOT APPLE) endif() set(Boost_USE_MULTITHREADED ON) set(__boost_packages filesystem regex system thread date_time) + if(WITH_CYCLES_OSL) + if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")) + list(APPEND __boost_packages wave) + else() + endif() + endif() if(WITH_INTERNATIONAL) list(APPEND __boost_packages locale) endif() @@ -1071,28 +1115,6 @@ if(UNIX AND NOT APPLE) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map") endif() - if(WITH_CYCLES_OSL) - set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") - - message(STATUS "CYCLES_OSL = ${CYCLES_OSL}") - - find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) - # Note: --whole-archive is needed to force loading of all symbols in liboslexec, - # otherwise LLVM is missing the osl_allocate_closure_component function - list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY}) - find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) - find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) - - if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) - set(OSL_FOUND TRUE) - else() - message(STATUS "OSL not found") - set(WITH_CYCLES_OSL OFF) - endif() - endif() - # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm) |