1 |
< |
cmake_minimum_required(VERSION 2.8.4) |
2 |
< |
project("radiance") |
1 |
> |
cmake_minimum_required(VERSION 3.5) |
2 |
> |
cmake_policy(SET CMP0020 NEW) |
3 |
> |
cmake_policy(SET CMP0048 NEW) |
4 |
> |
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.1") |
5 |
> |
cmake_policy(SET CMP0054 NEW) |
6 |
> |
endif() |
7 |
|
|
8 |
+ |
project(radiance VERSION 5.2.0) |
9 |
+ |
|
10 |
+ |
set(PROJECT_VERSION_TWEAK "Unknown" CACHE STRING "Commit Hash") |
11 |
+ |
find_package(Git) |
12 |
+ |
if(GIT_FOUND) |
13 |
+ |
execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short=10" "HEAD" |
14 |
+ |
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
15 |
+ |
TIMEOUT 10 |
16 |
+ |
RESULT_VARIABLE RESULT |
17 |
+ |
OUTPUT_VARIABLE GIT_VERSION |
18 |
+ |
ERROR_QUIET |
19 |
+ |
OUTPUT_STRIP_TRAILING_WHITESPACE |
20 |
+ |
) |
21 |
+ |
if(${RESULT} EQUAL 0 AND NOT "${GIT_VERSION}" EQUAL "${PROJECT_VERSION_TWEAK}") |
22 |
+ |
set(PROJECT_VERSION_TWEAK ${GIT_VERSION} CACHE STRING "Commit Hash" FORCE) |
23 |
+ |
endif() |
24 |
+ |
endif() |
25 |
+ |
|
26 |
|
enable_testing() |
27 |
|
include(CTest) |
28 |
|
|
29 |
|
option(BUILD_SHARED_LIBS "Build radiance using shared libraries?" OFF) |
30 |
+ |
option(BUILD_HEADLESS "Build radiance without any GUI components?" OFF) |
31 |
+ |
option(BUILD_PABOPTO_UTILS "Build PABOpto Utilities?" OFF) |
32 |
+ |
option(BUILD_LIBTIFF "Build libtiff?" OFF) |
33 |
+ |
option(BUILD_QT "Build Qt related stuff?" OFF) |
34 |
|
|
35 |
|
if(NOT WIN32) |
36 |
|
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1) |
37 |
< |
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/man/ DESTINATION man) |
37 |
> |
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/doc/man/" DESTINATION man) |
38 |
> |
if(BUILD_QT) |
39 |
> |
set(qt_plugin_term "PLUGIN") |
40 |
> |
endif() |
41 |
|
endif() |
42 |
|
|
43 |
+ |
if(WIN32) |
44 |
+ |
set(CPACK_NSIS_INSTALL_ROOT "C:") |
45 |
+ |
set(CPACK_NSIS_MODIFY_PATH 1) |
46 |
+ |
if(BUILD_QT) |
47 |
+ |
set(qt_plugin_term "LIBRARY") |
48 |
+ |
endif() |
49 |
|
|
50 |
< |
if (WIN32) |
50 |
> |
# Set RAYPATH on install |
51 |
> |
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS |
52 |
> |
"WriteRegExpandStr HKLM \\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\" RAYPATH '\\\$INSTDIR\\\\lib\\\;.'" |
53 |
> |
) |
54 |
|
|
55 |
< |
set(CPACK_NSIS_MODIFY_PATH 0) |
56 |
< |
|
57 |
< |
set(CPACK_BINARY_ZIP 1) |
58 |
< |
|
21 |
< |
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "") |
22 |
< |
|
55 |
> |
# Unset RAYPATH on uninstall |
56 |
> |
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS |
57 |
> |
"DeleteRegValue HKLM \\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\" RAYPATH" |
58 |
> |
) |
59 |
|
endif() |
60 |
|
|
61 |
|
if(UNIX) |
65 |
|
set(CPACK_PACKAGING_INSTALL_PREFIX "/") |
66 |
|
endif() |
67 |
|
|
68 |
+ |
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_TWEAK}-${CMAKE_SYSTEM_NAME}") |
69 |
+ |
|
70 |
|
if(APPLE) |
71 |
+ |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c11 -std=c++11 -stdlib=libc++") |
72 |
|
add_definitions(-DBSD -DNOSTEREO -Dfreebsd) |
73 |
< |
include_directories(/usr/X11R6/include) |
73 |
> |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}) |
74 |
> |
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7") |
75 |
|
endif() |
76 |
|
|
77 |
< |
set(CPACK_PACKAGE_VERSION_MAJOR 4) |
78 |
< |
set(CPACK_PACKAGE_VERSION_MINOR 2) |
79 |
< |
set(CPACK_PACKAGE_VERSION_PATCH a) |
77 |
> |
if(BUILD_LIBTIFF) |
78 |
> |
include(ExternalProject) |
79 |
> |
set(LIBTIFF_URL http://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz) |
80 |
> |
set(LIBTIFF_MD5 54BAD211279CC93EB4FCA31BA9BFDC79) |
81 |
> |
if(WIN32) |
82 |
> |
ExternalProject_Add(libtiff |
83 |
> |
URL ${LIBTIFF_URL} |
84 |
> |
URL_MD5 ${LIBTIFF_MD5} |
85 |
> |
CMAKE_GENERATOR "NMake Makefiles" |
86 |
> |
CMAKE_ARGS |
87 |
> |
"-UHAVE_UNISTD_H" |
88 |
> |
"-DBUILD_SHARED_LIBS=OFF" |
89 |
> |
"-DCMAKE_BUILD_TYPE=Release" |
90 |
> |
"-Dzlib=OFF" |
91 |
> |
"../libtiff" |
92 |
> |
INSTALL_COMMAND "" |
93 |
> |
) |
94 |
> |
set(TIFF_LIBRARY ${CMAKE_BINARY_DIR}/libtiff-prefix/src/libtiff-build/libtiff/tiff.lib) |
95 |
> |
else() |
96 |
> |
ExternalProject_Add(libtiff |
97 |
> |
URL ${LIBTIFF_URL} |
98 |
> |
URL_MD5 ${LIBTIFF_MD5} |
99 |
> |
CMAKE_ARGS |
100 |
> |
"-DBUILD_SHARED_LIBS=OFF" |
101 |
> |
"-DCMAKE_BUILD_TYPE=Release" |
102 |
> |
"-Dzlib=OFF" |
103 |
> |
"../libtiff" |
104 |
> |
INSTALL_COMMAND "" |
105 |
> |
) |
106 |
> |
set(TIFF_LIBRARY ${CMAKE_BINARY_DIR}/libtiff-prefix/src/libtiff-build/libtiff/libtiff.a) |
107 |
> |
endif() |
108 |
> |
set(TIFF_INCLUDE_DIR ${CMAKE_BINARY_DIR}/libtiff/src/libtiff/libtiff) |
109 |
> |
endif() |
110 |
> |
|
111 |
> |
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) |
112 |
> |
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) |
113 |
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Radiance") |
114 |
< |
SET(CPACK_RESOURCE_FILE_WELCOME "${radiance_SOURCE_DIR}/Welcome.txt") |
115 |
< |
SET(CPACK_RESOURCE_FILE_README "${radiance_SOURCE_DIR}/README.txt") |
116 |
< |
SET(CPACK_RESOURCE_FILE_LICENSE "${radiance_SOURCE_DIR}/License.txt") |
114 |
> |
set(CPACK_RESOURCE_FILE_WELCOME "${radiance_SOURCE_DIR}/Welcome.txt") |
115 |
> |
set(CPACK_RESOURCE_FILE_README "${radiance_SOURCE_DIR}/README.txt") |
116 |
> |
set(CPACK_RESOURCE_FILE_LICENSE "${radiance_SOURCE_DIR}/License.txt") |
117 |
|
|
118 |
+ |
if(APPLE) |
119 |
+ |
set(CPACK_GENERATOR "PackageMaker") |
120 |
+ |
elseif(UNIX) |
121 |
+ |
set(CPACK_GENERATOR "TGZ") |
122 |
+ |
endif() |
123 |
|
|
124 |
|
include(CPack) |
125 |
|
|
126 |
< |
find_package(Qt4 COMPONENTS QtCore QtGui) |
127 |
< |
find_package(X11) |
126 |
> |
if(NOT BUILD_HEADLESS) |
127 |
> |
if(BUILD_QT) |
128 |
> |
find_package(Qt5Widgets) |
129 |
> |
get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) |
130 |
> |
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) |
131 |
> |
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) |
132 |
> |
endif() |
133 |
> |
find_package(X11) |
134 |
> |
if(APPLE) |
135 |
> |
include_directories(${X11_INCLUDE_DIR}) |
136 |
> |
endif() |
137 |
> |
endif() |
138 |
|
|
139 |
< |
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) |
139 |
> |
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) |
140 |
|
|
141 |
+ |
if(MSVC) |
142 |
+ |
add_definitions(/MP) |
143 |
+ |
# Suppress warnings about double-to-float assignments and initializations |
144 |
+ |
add_compile_options(/wd"4244" /wd"4305") |
145 |
+ |
endif() |
146 |
|
if(WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") |
147 |
|
set(_INTEL_WINDOWS 1) |
148 |
|
endif() |
155 |
|
|
156 |
|
add_subdirectory("src") |
157 |
|
|
158 |
< |
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR}/test/test\ data) |
66 |
< |
option(BUILD_TESTING "Download support tarball & enable testing?" ON) |
158 |
> |
set(test_dir "${CMAKE_CURRENT_SOURCE_DIR}/test/test data") |
159 |
|
|
160 |
< |
if(BUILD_TESTING) |
69 |
< |
#download and extract radiance support files |
70 |
< |
include(ExternalProject) |
71 |
< |
set(base "${CMAKE_BINARY_DIR}/Downloads") |
72 |
< |
set_property(DIRECTORY PROPERTY EP_BASE ${base}) |
73 |
< |
ExternalProject_Add(radiance_support |
74 |
< |
URL http://www.radiance-online.org/software/non-cvs/rad4R1supp.tar.gz |
75 |
< |
URL_MD5 efd82970e1d0747eede8eb64c01048f4 |
76 |
< |
CONFIGURE_COMMAND "" |
77 |
< |
BUILD_COMMAND "" |
78 |
< |
INSTALL_COMMAND "" |
79 |
< |
) |
160 |
> |
add_subdirectory(resources) |
161 |
|
|
162 |
< |
#install support files. |
163 |
< |
set(lib_dir ${base}/Source/radiance_support/lib) |
164 |
< |
install( |
84 |
< |
FILES |
85 |
< |
${lib_dir}/Earth.cal ${lib_dir}/He.cal ${lib_dir}/He3.cal |
86 |
< |
${lib_dir}/adobe.cal ${lib_dir}/ball.cal ${lib_dir}/brick.cal |
87 |
< |
${lib_dir}/brickweave.cal ${lib_dir}/carpet.cal ${lib_dir}/climit.cal |
88 |
< |
${lib_dir}/corrug.cal ${lib_dir}/covelight.cal ${lib_dir}/cyl.cal |
89 |
< |
${lib_dir}/dichroic.cal ${lib_dir}/dirt.cal ${lib_dir}/fisheye.cal |
90 |
< |
${lib_dir}/fishgeom.cal ${lib_dir}/fprism.cal ${lib_dir}/globe.cal |
91 |
< |
${lib_dir}/gloss.cal ${lib_dir}/grating.cal ${lib_dir}/jigglepic.cal |
92 |
< |
${lib_dir}/lcp0.cal ${lib_dir}/limit.cal ${lib_dir}/marble.cal |
93 |
< |
${lib_dir}/orange.cal ${lib_dir}/picture.cal ${lib_dir}/plink.cal |
94 |
< |
${lib_dir}/prism.cal ${lib_dir}/retrorefl.cal ${lib_dir}/serraglaze.cal |
95 |
< |
${lib_dir}/slate.cal ${lib_dir}/surf.cal ${lib_dir}/tim1.cal |
96 |
< |
${lib_dir}/weave.cal ${lib_dir}/winxmit.cal ${lib_dir}/woodpat.cal |
97 |
< |
${lib_dir}/woodtex.cal ${lib_dir}/wrinkle.cal |
98 |
< |
${lib_dir}/page1.txt ${lib_dir}/page2.txt |
99 |
< |
${lib_dir}/Pix.fnt |
100 |
< |
${lib_dir}/PixOblique.fnt |
101 |
< |
${lib_dir}/Veerdana.fnt |
102 |
< |
${lib_dir}/VeerdanaBold.fnt |
103 |
< |
${lib_dir}/VeerdanaBoldItalic.fnt |
104 |
< |
${lib_dir}/VeerdanaItalic.fnt |
105 |
< |
${lib_dir}/helvet.fnt |
106 |
< |
${lib_dir}/hexbit4x1.fnt |
107 |
< |
${test_dir}/model.oct |
108 |
< |
${test_dir}/model.vp |
109 |
< |
DESTINATION lib |
110 |
< |
) |
162 |
> |
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/" |
163 |
> |
DESTINATION "lib" |
164 |
> |
) |
165 |
|
|
166 |
< |
install(FILES ${lib_dir}/Earth.hdr DESTINATION lib RENAME Earth.pic) |
167 |
< |
install(FILES ${lib_dir}/EarthBig.hdr DESTINATION lib RENAME EarthBig.pic) |
114 |
< |
install(FILES ${lib_dir}/alberta.hdr DESTINATION lib RENAME alberta.pic) |
115 |
< |
install(FILES ${lib_dir}/brick.hdr DESTINATION lib RENAME brick.pic) |
116 |
< |
install(FILES ${lib_dir}/brickweave.hdr DESTINATION lib RENAME brickweave.pic) |
117 |
< |
install(FILES ${lib_dir}/cabin.hdr DESTINATION lib RENAME cabin.pic) |
118 |
< |
install(FILES ${lib_dir}/forestfl.hdr DESTINATION lib RENAME forestfl.pic) |
119 |
< |
install(FILES ${lib_dir}/oakfloor.hdr DESTINATION lib RENAME oakfloor.pic) |
120 |
< |
install(FILES ${lib_dir}/pine.hdr DESTINATION lib RENAME pine.pic) |
121 |
< |
install(FILES ${lib_dir}/pinebark.hdr DESTINATION lib RENAME pinebark.pic) |
122 |
< |
install(FILES ${lib_dir}/podlife.hdr DESTINATION lib RENAME podlife.pic) |
123 |
< |
install(FILES ${lib_dir}/richgrove.hdr DESTINATION lib RENAME richgrove.pic) |
124 |
< |
install(FILES ${lib_dir}/shingle.hdr DESTINATION lib RENAME shingle.pic) |
125 |
< |
install(FILES ${lib_dir}/summercab.hdr DESTINATION lib RENAME summercab.pic) |
126 |
< |
install(FILES ${lib_dir}/tulips.hdr DESTINATION lib RENAME tulips.pic) |
166 |
> |
# copy make tests to build |
167 |
> |
file(COPY test DESTINATION ${CMAKE_BINARY_DIR}) |
168 |
|
|
128 |
– |
add_subdirectory(cmake_tests) |
129 |
– |
endif() |
130 |
– |
|
131 |
– |
install( |
132 |
– |
FILES |
133 |
– |
${test_dir}/model.oct |
134 |
– |
${test_dir}/model.vp |
135 |
– |
DESTINATION lib |
136 |
– |
) |
169 |
|
|
170 |
|
include(InstallRequiredSystemLibraries) |
171 |
|
add_subdirectory(InstallRules) |