From 9b8942ac71cfe000b1402c5379342c2f1be2b288 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 16 Nov 2014 18:01:10 +0500 Subject: [PATCH] Cycles Standalone: Add initial support for compilation on Windows This applies to an application comiling from the standalone Cycles repository only. There's still lack of proper install target, so currently pthreads library is to be copied next to cycles.exe manually. --- intern/cycles/app/CMakeLists.txt | 26 +++++++++++++++++++++--- intern/cycles/cmake/external_libs.cmake | 27 +++++++++++++++++-------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index d48ef51ded4..baa0fdde7f3 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -20,10 +20,8 @@ set(LIBRARIES cycles_subd cycles_util ${BOOST_LIBRARIES} - ${OPENEXR_LIBRARIES} ${BLENDER_GL_LIBRARIES} ${CYCLES_APP_GLEW_LIBRARY} - ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} @@ -33,6 +31,27 @@ set(LIBRARIES extern_cuew ) +macro(target_link_libraries_oiio target) + if(NOT MSVC) + target_link_libraries(${target} + ${OPENIMAGEIO_LIBRARIES} + ${OPENEXR_LIBRARIES}) + else() + # For MSVC we link to different libraries depending whether + # release or debug target is being built. + file_list_suffix(OPENIMAGEIO_LIBRARIES_DEBUG "${OPENIMAGEIO_LIBRARIES}" "_d") + file_list_suffix(OPENIMAGEIO_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d") + + target_link_libraries_debug("${target}" "${OPENIMAGEIO_LIBRARIES_DEBUG}") + target_link_libraries_debug("${target}" "${OPENEXR_LIBRARIES_DEBUG}") + target_link_libraries_optimized("${target}" "${OPENIMAGEIO_LIBRARIES}") + target_link_libraries_optimized("${target}" "${OPENEXR_LIBRARIES}") + + unset(OPENIMAGEIO_LIBRARIES_DEBUG) + unset(OPENIMAGEIO_LIBRARIES_DEBUG) + endif() +endmacro() + if(NOT PUGIXML_LIBRARIES STREQUAL "") list(APPEND LIBRARIES ${PUGIXML_LIBRARIES}) endif() @@ -78,6 +97,7 @@ if(WITH_CYCLES_STANDALONE) add_executable(cycles ${SRC}) list(APPEND LIBRARIES ${PLATFORM_LINKLIBS}) target_link_libraries(cycles ${LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries_oiio(cycles) if(UNIX AND NOT APPLE) set_target_properties(cycles PROPERTIES INSTALL_RPATH $ORIGIN/lib) @@ -91,10 +111,10 @@ if(WITH_CYCLES_NETWORK) ) add_executable(cycles_server ${SRC}) target_link_libraries(cycles_server ${LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries_oiio(cycles_server) if(UNIX AND NOT APPLE) set_target_properties(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib) endif() unset(SRC) endif() - diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index 465f2d27cf9..00c9b5179d6 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -1,3 +1,12 @@ +########################################################################### +# Precompiled libraries tips and hints, for find_package(). + +if(CYCLES_STANDALONE_REPOSITORY) + if(APPLE OR WIN32) + include(precompiled_libs) + endif() +endif() + ########################################################################### # GLUT @@ -42,13 +51,13 @@ endif() # source code. but which we need to take care of when building Cycles from a # standalone repository if(CYCLES_STANDALONE_REPOSITORY) - if(APPLE OR WIN32) - include(precompiled_libs) - endif() - # PThreads - find_package(Threads REQUIRED) - set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + # TODO(sergey): Bloody exception, handled in precompiled_libs.cmake. + if(NOT WIN32) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + find_package(Threads REQUIRED) + set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + endif() #### # OpenGL @@ -83,10 +92,12 @@ if(CYCLES_STANDALONE_REPOSITORY) if(WITH_CYCLES_NETWORK) list(APPEND __boost_packages serialization) endif() - if(WITH_CYCLES_OSL AND APPLE) + if(WITH_CYCLES_OSL) # TODO(sergey): This is because of the way how our precompiled # libraries works, could be different for someone's else libs.. - list(APPEND __boost_packages wave) + if(APPLE OR MSVC) + list(APPEND __boost_packages wave) + endif() endif() find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED) if(NOT Boost_FOUND)