[Bf-blender-cvs] [f04260d8c67] master: CMake: refresh building and external library handling of Cycles standalone

Brecht Van Lommel noreply at git.blender.org
Fri Sep 4 19:11:16 CEST 2020


Commit: f04260d8c679851be6a267214daacae44126156f
Author: Brecht Van Lommel
Date:   Fri Sep 4 18:41:10 2020 +0200
Branches: master
https://developer.blender.org/rBf04260d8c679851be6a267214daacae44126156f

CMake: refresh building and external library handling of Cycles standalone

* Support precompiled libraries on Linux
* Add license headers
* Refactoring to deduplicate code

Includes work by Ray Molenkamp and Grische for precompiled libraries.

Ref D8769

===================================================================

M	intern/cycles/CMakeLists.txt
M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/blender/CMakeLists.txt
M	intern/cycles/bvh/CMakeLists.txt
M	intern/cycles/cmake/external_libs.cmake
M	intern/cycles/cmake/macros.cmake
M	intern/cycles/device/CMakeLists.txt
M	intern/cycles/doc/CMakeLists.txt
M	intern/cycles/doc/license/CMakeLists.txt
M	intern/cycles/graph/CMakeLists.txt
M	intern/cycles/kernel/CMakeLists.txt
M	intern/cycles/kernel/osl/CMakeLists.txt
M	intern/cycles/kernel/shaders/CMakeLists.txt
M	intern/cycles/render/CMakeLists.txt
M	intern/cycles/subd/CMakeLists.txt
M	intern/cycles/test/CMakeLists.txt
M	intern/cycles/util/CMakeLists.txt

===================================================================

diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 0dd182526b1..d114820d723 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -1,3 +1,17 @@
+# Copyright 2011-2020 Blender Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 # Standalone or with Blender
 if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
   set(CYCLES_INSTALL_PATH "")
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index a2b0ed03925..67b852013f3 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -1,3 +1,20 @@
+# Copyright 2011-2020 Blender Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#####################################################################
+# Cycles standalone executable
+#####################################################################
 
 set(INC
   ..
@@ -5,8 +22,6 @@ set(INC
 set(INC_SYS
 )
 
-# NOTE: LIBRARIES contains all the libraries which are common
-# across release and debug build types, stored in a linking order.
 set(LIBRARIES
   cycles_device
   cycles_kernel
@@ -15,96 +30,33 @@ set(LIBRARIES
   cycles_subd
   cycles_graph
   cycles_util
-  ${BLENDER_GL_LIBRARIES}
-  ${CYCLES_APP_GLEW_LIBRARY}
-  ${PNG_LIBRARIES}
-  ${JPEG_LIBRARIES}
-  ${ZLIB_LIBRARIES}
-  ${TIFF_LIBRARY}
-  ${PTHREADS_LIBRARIES}
 )
 
-if(WITH_CUDA_DYNLOAD)
-  list(APPEND LIBRARIES extern_cuew)
-else()
-  list(APPEND LIBRARIES ${CUDA_CUDA_LIBRARY})
-endif()
-
 if(WITH_CYCLES_OSL)
   list(APPEND LIBRARIES cycles_kernel_osl)
 endif()
 
-if(NOT CYCLES_STANDALONE_REPOSITORY)
-  list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc bf_intern_numaapi bf_intern_sky)
-endif()
-
-if(WITH_CYCLES_LOGGING)
-  list(APPEND LIBRARIES
-    ${GLOG_LIBRARIES}
-    ${GFLAGS_LIBRARIES}
-  )
+if(CYCLES_STANDALONE_REPOSITORY)
+  list(APPEND LIBRARIES extern_sky)
+else()
+  list(APPEND LIBRARIES bf_intern_sky)
 endif()
 
 if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
   list(APPEND LIBRARIES ${GLUT_LIBRARIES})
 endif()
 
-# Common configuration.
+list(APPEND LIBRARIES ${CYCLES_GL_LIBRARIES})
 
-link_directories(
-  ${OPENIMAGEIO_LIBPATH}
-  ${BOOST_LIBPATH}
-  ${PNG_LIBPATH}
-  ${JPEG_LIBPATH}
-  ${ZLIB_LIBPATH}
-  ${TIFF_LIBPATH}
-  ${OPENEXR_LIBPATH}
-  ${OPENJPEG_LIBPATH}
-  ${OPENVDB_LIBPATH}
-)
+# Common configuration.
 
-if(WITH_OPENCOLORIO)
-  link_directories(${OPENCOLORIO_LIBPATH})
-endif()
+cycles_link_directories()
 
 add_definitions(${GL_DEFINITIONS})
 
 include_directories(${INC})
 include_directories(SYSTEM ${INC_SYS})
 
-# Make sure given target is linked against proper libraries
-# which varies across debug and release build types.
-#
-# This will also make sure dependencies of that libraries
-# are sent to the linker after them.
-#
-# TODO(sergey): Think of a better place for this?
-macro(cycles_target_link_libraries target)
-  target_link_libraries(${target} ${LIBRARIES})
-  if(WITH_CYCLES_OSL)
-    target_link_libraries(${target} ${OSL_LIBRARIES} ${LLVM_LIBRARIES})
-  endif()
-  if(WITH_CYCLES_EMBREE)
-    target_link_libraries(${target} ${EMBREE_LIBRARIES})
-  endif()
-  if(WITH_OPENSUBDIV)
-    target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
-  endif()
-  if(WITH_OPENCOLORIO)
-    target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
-  endif()
-  target_link_libraries(
-    ${target}
-    ${OPENIMAGEIO_LIBRARIES}
-    ${OPENEXR_LIBRARIES}
-    ${OPENJPEG_LIBRARIES}
-    ${PUGIXML_LIBRARIES}
-    ${BOOST_LIBRARIES}
-    ${CMAKE_DL_LIBS}
-    ${PLATFORM_LINKLIBS}
-  )
-endmacro()
-
 # Application build targets
 
 if(WITH_CYCLES_STANDALONE)
@@ -113,20 +65,31 @@ if(WITH_CYCLES_STANDALONE)
     cycles_xml.cpp
     cycles_xml.h
   )
-  add_executable(cycles ${SRC})
+  add_executable(cycles ${SRC} ${INC} ${INC_SYS})
+  unset(SRC)
+
+  target_link_libraries(cycles ${LIBRARIES})
   cycles_target_link_libraries(cycles)
 
   if(UNIX AND NOT APPLE)
     set_target_properties(cycles PROPERTIES INSTALL_RPATH $ORIGIN/lib)
   endif()
-  unset(SRC)
+
+  if(CYCLES_STANDALONE_REPOSITORY)
+    cycles_install_libraries(cycles)
+  endif()
 endif()
 
+#####################################################################
+# Cycles network server executable
+#####################################################################
+
 if(WITH_CYCLES_NETWORK)
   set(SRC
     cycles_server.cpp
   )
   add_executable(cycles_server ${SRC})
+  target_link_libraries(cycles_server ${LIBRARIES})
   cycles_target_link_libraries(cycles_server)
 
   if(UNIX AND NOT APPLE)
@@ -135,6 +98,10 @@ if(WITH_CYCLES_NETWORK)
   unset(SRC)
 endif()
 
+#####################################################################
+# Cycles cubin compiler executable
+#####################################################################
+
 if(WITH_CYCLES_CUBIN_COMPILER)
   # 32 bit windows is special, nvrtc is not supported on x86, so even
   # though we are building 32 bit blender a 64 bit cubin_cc will have
@@ -151,18 +118,7 @@ if(WITH_CYCLES_CUBIN_COMPILER)
     )
     add_executable(cycles_cubin_cc ${SRC})
     include_directories(${INC})
-    target_link_libraries(cycles_cubin_cc
-      extern_cuew
-      ${OPENIMAGEIO_LIBRARIES}
-      ${OPENEXR_LIBRARIES}
-      ${OPENJPEG_LIBRARIES}
-      ${PUGIXML_LIBRARIES}
-      ${BOOST_LIBRARIES}
-      ${PLATFORM_LINKLIBS}
-    )
-    if(NOT CYCLES_STANDALONE_REPOSITORY)
-      target_link_libraries(cycles_cubin_cc bf_intern_guardedalloc)
-    endif()
+    cycles_target_link_libraries(cycles_cubin_cc)
     unset(SRC)
     unset(INC)
   endif()
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index e0fa45dffbc..0d805dc8683 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -1,3 +1,16 @@
+# Copyright 2011-2020 Blender Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 set(INC
   ..
diff --git a/intern/cycles/bvh/CMakeLists.txt b/intern/cycles/bvh/CMakeLists.txt
index 8b8f3ca7265..703c69b1797 100644
--- a/intern/cycles/bvh/CMakeLists.txt
+++ b/intern/cycles/bvh/CMakeLists.txt
@@ -1,3 +1,16 @@
+# Copyright 2011-2020 Blender Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 set(INC
   ..
diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index b09f442bd16..e84dc7a1fca 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -1,83 +1,152 @@
+# Copyright 2011-2020 Blender Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+###########################################################################
+# Helper macros
 ###########################################################################
-# Precompiled libraries tips and hints, for find_package().
 
-if(CYCLES_STANDALONE_REPOSITORY)
-  if(APPLE OR WIN32)
-    include(precompiled_libs)
-  endif()
-endif()
+macro(_set_default variable value)
+	if(NOT ${variable})
+		set(${variable} ${value})
+	endif()
+endmacro()
 
 ###########################################################################
-# GLUT
+# Precompiled libraries detection
+#
+# Use precompiled libraries from Blender repository
+###########################################################################
 
-if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
-  set(GLUT_ROOT_PATH ${CYCLES_GLUT})
+if(CYCLES_STANDALONE_REPOSITORY)
+  if(APPLE)
+    set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin")
+  elseif(WIN32)
+    if(CMAKE_CL_64)
+      set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/win64_vc15")
+    else()
+      message(FATAL_ERROR "Unsupported Visual Studio Version")
+    endif()
+  else()
+    # Path to a lo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list