Merging r50522 through r50572 from trunk into soc-2011-tomato
[blender.git] / build_files / cmake / macros.cmake
index 3d2d19c7685a8ac93e9654df045bd717a691fc8a..ad5e3155368d0566d62f01c7039d142cea4787d7 100644 (file)
@@ -27,7 +27,10 @@ macro(list_insert_after
        list_id item_check item_add
        )
        set(_index)
-       list(FIND ${list_id} "${item_check}" _index)
+       list(FIND "${list_id}" "${item_check}" _index)
+       if("${_index}" MATCHES "-1")
+               message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'")
+       endif()
        math(EXPR _index "${_index} + 1")
        list(INSERT ${list_id} "${_index}" ${item_add})
        unset(_index)
@@ -37,7 +40,10 @@ macro(list_insert_before
        list_id item_check item_add
        )
        set(_index)
-       list(FIND ${list_id} "${item_check}" _index)
+       list(FIND "${list_id}" "${item_check}" _index)
+       if("${_index}" MATCHES "-1")
+               message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'")
+       endif()
        list(INSERT ${list_id} "${_index}" ${item_add})
        unset(_index)
 endmacro()
@@ -212,6 +218,9 @@ macro(SETUP_LIBDIRS)
        if(WITH_OPENIMAGEIO)
                link_directories(${OPENIMAGEIO_LIBPATH})
        endif()
+       if(WITH_OPENCOLORIO)
+               link_directories(${OPENCOLORIO_LIBPATH})
+       endif()
        if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
                link_directories(${OPENJPEG_LIBPATH})
        endif()
@@ -307,6 +316,9 @@ macro(setup_liblinks
        if(WITH_OPENIMAGEIO)
                target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
        endif()
+       if(WITH_OPENCOLORIO)
+               target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
+       endif()
        if(WITH_BOOST)
                target_link_libraries(${target} ${BOOST_LIBRARIES})
        endif()
@@ -367,6 +379,9 @@ macro(setup_liblinks
        if(WITH_MOD_CLOTH_ELTOPO)
                target_link_libraries(${target} ${LAPACK_LIBRARIES})
        endif()
+       if(WITH_CYCLES_OSL)
+               target_link_libraries(${target} ${OSL_LIBRARIES})
+       endif()
        if(WIN32 AND NOT UNIX)
                target_link_libraries(${target} ${PTHREADS_LIBRARIES})
        endif()
@@ -727,7 +742,6 @@ macro(set_lib_path
 endmacro()
 
 
-# TODO, create a C binary and call it instead!, doing this in cmake its slow
 macro(data_to_c
       file_from file_to
       list_to_add)
@@ -739,34 +753,32 @@ macro(data_to_c
        add_custom_command(
                OUTPUT ${file_to}
                COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
-               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc
-                       ${file_from}
-                       ${file_to}
-               DEPENDS ${file_from})
+               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${file_from} ${file_to}
+               DEPENDS ${file_from} datatoc)
        unset(_file_to_path)
 endmacro()
 
+
 # same as above but generates the var name and output automatic.
 macro(data_to_c_simple
       file_from
       list_to_add)
 
-       # only to avoid confusion
-       set(_file_to ${file_from}.c)
+       # remove ../'s
+       get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from}   REALPATH)
+       get_filename_component(_file_to   ${CMAKE_CURRENT_BINARY_DIR}/${file_from}.c REALPATH)
 
-       list(APPEND ${list_to_add} ${CMAKE_CURRENT_BINARY_DIR}/${_file_to})
+       list(APPEND ${list_to_add} ${_file_to})
 
        get_filename_component(_file_to_path ${_file_to} PATH)
 
        add_custom_command(
-               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
+               OUTPUT  ${_file_to}
                COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
-               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc
-                       ${CMAKE_CURRENT_SOURCE_DIR}/${file_from}
-                       ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
-               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_from})
+               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${_file_from} ${_file_to}
+               DEPENDS ${_file_from} datatoc)
 
-       unset(_var_name)
+       unset(_file_from)
        unset(_file_to)
        unset(_file_to_path)
 endmacro()