diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f3119..5cfa601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,34 +244,49 @@ else(USE_EXTERNAL_TINYXML) endif() set_target_properties(TINYXML_LIB PROPERTIES FOLDER External) endif(USE_EXTERNAL_TINYXML) - + ############################################################################### ### YAML ### if(USE_EXTERNAL_YAML) - # Set minimum yaml version for non-patched sources. - set(YAML_VERSION_MIN "0.3.0") - include(FindPkgConfig) - pkg_check_modules(PC_YAML_CPP REQUIRED QUIET yaml-cpp) - find_path(YAML_CPP_INCLUDE_DIR yaml-cpp/yaml.h - HINTS ${PC_YAML_CPP_INCLUDEDIR} ${PC_YAML_CPP_INCLUDE_DIRS} ) - find_library(YAML_CPP_LIBRARY LIBRARY_NAMES yaml-cpp libyaml-cpp - HINTS ${PC_YAML_CPP_LIBRARY_DIRS} ) - set(YAML_CPP_LIBRARIES ${YAML_CPP_LIBRARY}) - set(YAML_CPP_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR}) - set(YAML_CPP_VERSION ${PC_YAML_CPP_VERSION}) - - if(YAML_CPP_VERSION VERSION_LESS ${YAML_VERSION_MIN}) - message(FATAL_ERROR "ERROR: yaml-cpp ${YAML_VERSION_MIN} or greater is required.") - endif() + find_package(yaml-cpp 0.3.0) + if(yaml-cpp_FOUND) + include(FindPackageMessage) + + set(YAML_CPP_FOUND ${yaml-cpp_FOUND}) + set(YAML_CPP_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR}) + set(YAML_CPP_VERSION ${yaml-cpp_VERSION}) + set(YAML_CPP_LIBRARIES yaml-cpp) + + find_package_message(yaml-cpp + "Found yaml ${YAML_CPP_VERSION}: ${YAML_CPP_INCLUDE_DIRS}" + "${YAML_CPP_INCLUDE_DIRS}:${YAML_CPP_LIBRARIES}" + ) + else() + # Set minimum yaml version for non-patched sources. + set(YAML_VERSION_MIN "0.3.0") + include(FindPkgConfig) + pkg_check_modules(PC_YAML_CPP REQUIRED QUIET yaml-cpp) + find_path(YAML_CPP_INCLUDE_DIR yaml-cpp/yaml.h + HINTS ${PC_YAML_CPP_INCLUDEDIR} ${PC_YAML_CPP_INCLUDE_DIRS} ) + find_library(YAML_CPP_LIBRARY LIBRARY_NAMES yaml-cpp libyaml-cpp + HINTS ${PC_YAML_CPP_LIBRARY_DIRS} ) + set(YAML_CPP_LIBRARIES ${YAML_CPP_LIBRARY}) + set(YAML_CPP_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR}) + set(YAML_CPP_VERSION ${PC_YAML_CPP_VERSION}) + + if(YAML_CPP_VERSION VERSION_LESS ${YAML_VERSION_MIN}) + message(FATAL_ERROR "ERROR: yaml-cpp ${YAML_VERSION_MIN} or greater is required.") + endif() - find_package_handle_standard_args(yaml-cpp - REQUIRED_VARS YAML_CPP_LIBRARIES YAML_CPP_INCLUDE_DIRS ) - set(YAML_CPP_FOUND ${YAML-CPP_FOUND}) - mark_as_advanced(YAML_CPP_INCLUDE_DIR YAML_CPP_LIBRARY YAML-CPP_FOUND) + find_package_handle_standard_args(yaml-cpp + REQUIRED_VARS YAML_CPP_LIBRARIES YAML_CPP_INCLUDE_DIRS ) + set(YAML_CPP_FOUND ${YAML-CPP_FOUND}) + mark_as_advanced(YAML_CPP_INCLUDE_DIR YAML_CPP_LIBRARY YAML-CPP_FOUND) + endif() if(YAML_CPP_FOUND) - if(YAML_CPP_VERSION VERSION_GREATER "0.5.0") + if(YAML_CPP_VERSION VERSION_GREATER "0.5.0" AND YAML_CPP_VERSION VERSION_LESS "0.6.0") # Need to also get the boost headers here, as yaml-cpp 0.5.0+ requires them. # Don't bother doing this step if we are already including the boost headers for shared_ptr if(NOT OCIO_USE_BOOST_PTR) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4b931ef..12a1dbf 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -77,7 +77,14 @@ endif() if(OCIO_BUILD_STATIC) list(REMOVE_ITEM core_src_files ${CMAKE_SOURCE_DIR}/src/core/UnitTest.cpp) add_library(OpenColorIO_STATIC STATIC ${EXTERNAL_OBJECTS} ${core_src_files}) - add_dependencies(OpenColorIO_STATIC TINYXML_LIB YAML_CPP_LIB) + add_dependencies(OpenColorIO_STATIC TINYXML_LIB) + + if(USE_EXTERNAL_YAML) + target_link_libraries(OpenColorIO_STATIC ${YAML_CPP_LIBRARIES}) + else(USE_EXTERNAL_YAML) + add_dependencies(OpenColorIO_STATIC YAML_CPP_LIB) + endif() + if(EXTERNAL_LIBRARIES) target_link_libraries(OpenColorIO_STATIC ${EXTERNAL_LIBRARIES}) endif() diff --git a/src/core/OCIOYaml.cpp b/src/core/OCIOYaml.cpp index aeee4d1..f1c662d 100644 --- a/src/core/OCIOYaml.cpp +++ b/src/core/OCIOYaml.cpp @@ -69,7 +69,7 @@ namespace YAML { #ifdef WIN32 #pragma warning( push ) -#pragma warning( disable: 4146 ) +#pragma warning( disable: 4146 4251 ) #endif #include