Scons: refactor cycles kernel code to avoid building the AVX kernel with
[blender.git] / intern / cycles / CMakeLists.txt
1
2 # Standalone or with Blender
3 if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
4         set(CYCLES_INSTALL_PATH "")
5 else()
6         set(WITH_CYCLES_BLENDER ON)
7         set(CYCLES_INSTALL_PATH "scripts/addons/cycles")
8 endif()
9
10 # External Libraries
11
12 include(cmake/external_libs.cmake)
13
14 # Build Flags
15 # todo: refactor this code to match scons
16
17 if(WIN32 AND MSVC)
18         # there is no /arch:SSE3, but intrinsics are available anyway
19         if(CMAKE_CL_64)
20                 set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
21                 set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
22                 set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
23                 set(CYCLES_AVX_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") #/arch:AVX for VC2012 and above
24         else()
25                 set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
26                 set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
27                 set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
28                 set(CYCLES_AVX_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") #/arch:AVX for VC2012 and above
29         endif()
30
31         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
32         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
33         set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox")
34         set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Ox")
35 elseif(CMAKE_COMPILER_IS_GNUCC)
36         set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
37         set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
38         set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse")
39         set(CYCLES_AVX_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mfpmath=sse")
40         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
41 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
42         set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2")
43         set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3")
44         set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1")
45         set(CYCLES_AVX_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx")
46         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
47 endif()
48
49 add_definitions(-DWITH_KERNEL_SSE2 -DWITH_KERNEL_SSE3 -DWITH_KERNEL_SSE41 -DWITH_KERNEL_AVX)
50
51 # for OSL
52 if(WIN32 AND MSVC)
53         set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
54 elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
55         set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
56 endif()
57
58 # Definitions and Includes
59
60 add_definitions(${BOOST_DEFINITIONS} ${OPENIMAGEIO_DEFINITIONS})
61
62 add_definitions(-DCCL_NAMESPACE_BEGIN=namespace\ ccl\ {)
63 add_definitions(-DCCL_NAMESPACE_END=})
64
65 if(WITH_CYCLES_NETWORK)
66         add_definitions(-DWITH_NETWORK)
67 endif()
68
69 if(WITH_CYCLES_STANDALONE_GUI)
70         add_definitions(-DWITH_CYCLES_STANDALONE_GUI)
71 endif()
72
73 if(WITH_CYCLES_PTEX)
74         add_definitions(-DWITH_PTEX)
75 endif()
76
77 if(WITH_CYCLES_OPENSUBDIV)
78         add_definitions(-DWITH_OPENSUBDIV)
79 endif()
80
81 if(WITH_CYCLES_OSL)
82         add_definitions(-DWITH_OSL)
83         add_definitions(-DOSL_STATIC_LIBRARY)
84         include_directories(${OSL_INCLUDES})
85 endif()
86
87 add_definitions(-DWITH_OPENCL)
88 add_definitions(-DWITH_CUDA)
89 add_definitions(-DWITH_MULTI)
90
91 include_directories(
92         SYSTEM
93         ${BOOST_INCLUDE_DIR}
94         ${OPENIMAGEIO_INCLUDE_DIRS}
95         ${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO
96         ${OPENEXR_INCLUDE_DIR}
97         ${OPENEXR_INCLUDE_DIRS})
98
99 # Subdirectories
100
101 if(WITH_CYCLES_BLENDER)
102         add_subdirectory(blender)
103 endif()
104
105 if(WITH_CYCLES_STANDALONE OR WITH_CYCLES_NETWORK)
106         add_subdirectory(app)
107 endif()
108
109 add_subdirectory(bvh)
110 add_subdirectory(device)
111 add_subdirectory(doc)
112 add_subdirectory(kernel)
113 add_subdirectory(render)
114 add_subdirectory(subd)
115 add_subdirectory(util)
116
117 if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
118         delayed_do_install(${CMAKE_BINARY_DIR}/bin)
119 endif()
120