compile radiance HEAD 3332 with cmake on command line / linux

Hi Denny,

Yeah there really isn't any documentation on the NREL site on how to actually use the CMake build system in the Radiance source tree, yet. Pally at IESve wrote up a great summary of her experience using CMake and posted it here a couple/few months ago.

Sounds like you have CMake on your system. The quick bullet list of steps I do is as follows:

1. create build directory in ray/
2. cd ray/build
3. cmake ..
4. ccmake .
4a. In the ccmake "gui", type 'c' to configure, fix any errors found
4b. Type 'g' to generate themakefiles; ccmake will then exit
5. make
if all goes well, then:
6. sudo make install

Lemme know if that helps.

- Rob

···

________________________________________
From: Denny [[email protected]]
Sent: Tuesday, October 23, 2012 9:10 AM
To: [email protected]
Subject: [Radiance-dev] compile radiance HEAD 3332 with cmake on command line / linux

Dear all,

I tried to compile radiance HEAD 3332 from source (snapshot) on an openSUSE 12.2 64bit box with cmake 2.8.9; gcc 4.7.1, but don't get a working version of radiance.

As I couldn't find much documentation on the cmake build for radiance and I haven't used cmake much, It would be good to get some guidance.

Here is what I did:

1. Untar src

/> tar xvf radiance-HEAD-ecd3332.tar.gz

2. change into directory and call cmake

/>cd radiance-HEAD-ecd3332

/>cmake src/

Everything looks good, except for the following warning:

CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower

if you wish to support older CMake versions for this project. For more

information run "cmake --help-policy CMP0000".

This warning is for project developers. Use -Wno-dev to suppress it.

3. Build binaries from source

/>make -i

4. Install

/>make install -i

Following things I noticed:

1. Build fails when not using -i with make, as there are many issues regarding a missing Version.c file, like:

:

[ 37%] Built target genworm

[ 37%] Generating /src/rt/Version.c

CMake Error: Error processing file:/src/rt/create_version.cmake

make[2]: *** [/src/rt/Version.c] Error 1

make[1]: *** [rt/CMakeFiles/radiance.dir/all] Error 2

make: *** [all] Error 2

2. There is no build/ directory created when building that holds the resulting binaries etc.

Questions:

1. Is there anything obvious, I should do differently?

2. How do I install executables etc. to /usr/ rather than /usr/local/ e.g /usr/bin or /usr/share/radiance/ etc. without patching the sources/cmake files?

Thanks for your help.

Denny

Hey Robert,
thank you for your reply. It actually did help a bit.

I still found several issues when compiling/installing, I couldn't get solved
yet.

1. Install Paths
I can't use an interactive build process, so the ccmake option does not work
in this case.
Instead, I tried to pass parameters to the cmake call to adjust install
directories etc.
e.g.
cmake -DCMAKE_INSTALL_PREFIX="/usr/"

The result is: with make install, everything ends up under "/usr/" (instead of
/usr/local/), even man, lib etc. and not where it should be. I tried passing
those with parameters as well, but they've got ignored by cmake.

2. radiance_support
when running make, it tries to download the rad4R1supp package. I'd prefer to
just provide the already downloaded archive, which does not seemed to be well
supported by the cmake/make system.
However, I placed the archive under the manually created directory
build/Downloads/Download/radiance_support/ .

The problem here seems to be, that the make script seems to accept it (no
download), but nothing from that gets actually build/installed.

If all goes well, I should get some rpm's with the open-build-service in the
end. You can follow the progress on

https://build.opensuse.org/package/show?package=radiance&project=home%3Alumnis

However, there are quite a few things left to get there.

The cmake setup needs some improvements, at the moment a number of "hacks" are
needed to get the current state, which could be fixed in the cmake setup,
mainly the path/install issues.

Any comments/help would be appreciated.

Denny

···

Am Dienstag, 23. Oktober 2012, 10:36:47 schrieb Guglielmetti, Robert:

Hi Denny,

Yeah there really isn't any documentation on the NREL site on how to
actually use the CMake build system in the Radiance source tree, yet. Pally
at IESve wrote up a great summary of her experience using CMake and posted
it here a couple/few months ago.

Sounds like you have CMake on your system. The quick bullet list of steps I
do is as follows:

1. create build directory in ray/
2. cd ray/build
3. cmake ..
4. ccmake .
4a. In the ccmake "gui", type 'c' to configure, fix any errors found
4b. Type 'g' to generate themakefiles; ccmake will then exit
5. make
if all goes well, then:
6. sudo make install

Lemme know if that helps.

- Rob

________________________________________
From: Denny [[email protected]]
Sent: Tuesday, October 23, 2012 9:10 AM
To: [email protected]
Subject: [Radiance-dev] compile radiance HEAD 3332 with cmake on command
   line / linux

Dear all,

I tried to compile radiance HEAD 3332 from source (snapshot) on an openSUSE
12.2 64bit box with cmake 2.8.9; gcc 4.7.1, but don't get a working version
of radiance.

As I couldn't find much documentation on the cmake build for radiance and I
haven't used cmake much, It would be good to get some guidance.

Here is what I did:

1. Untar src

/> tar xvf radiance-HEAD-ecd3332.tar.gz

2. change into directory and call cmake

/>cd radiance-HEAD-ecd3332

/>cmake src/

Everything looks good, except for the following warning:

CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower

if you wish to support older CMake versions for this project. For more

information run "cmake --help-policy CMP0000".

This warning is for project developers. Use -Wno-dev to suppress it.

3. Build binaries from source

/>make -i

4. Install

/>make install -i

Following things I noticed:

1. Build fails when not using -i with make, as there are many issues
regarding a missing Version.c file, like:

[ 37%] Built target genworm

[ 37%] Generating /src/rt/Version.c

CMake Error: Error processing file:/src/rt/create_version.cmake

make[2]: *** [/src/rt/Version.c] Error 1

make[1]: *** [rt/CMakeFiles/radiance.dir/all] Error 2

make: *** [all] Error 2

2. There is no build/ directory created when building that holds the
resulting binaries etc.

Questions:

1. Is there anything obvious, I should do differently?

2. How do I install executables etc. to /usr/ rather than /usr/local/ e.g
/usr/bin or /usr/share/radiance/ etc. without patching the sources/cmake
files?

Thanks for your help.

Denny

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev

Dear all,
I'm still not sure, whether the build process does what it supposed to do.

What exactly is the difference in when enabling "BUILD_SHARED_LIBS" for the
build process. I tried the two options with different (problematic) results:

[1] When using the normal call
/>cmake ..
It seems, that all binaries/programs got build and installed to
/usr/local/bin/
Following issues:
[1-i1] Some librarie-files also end up under bin/, where they shouldn't be, eg.
- plugins/imageformats/libqgif.so", libqico.so, etc.
- libradiance.a and other *.a files
- objview.rb
- qt.conf
etc.
[1-i2] there is an error about the "/usr/local/bin/wish4.0" . I know wish is
used for tk, but why is in radiance. Shouldn't be tk rather be installed on
the system, that shipping tk with radiance?

[2] When I used
/>cmake -DBUILD_SHARED_LIBS="ON" ..

following issues are generated:
[2-i1] almost no progams are build due to linking errors as follows:
Linking C executable ../../bin/rcalc
../common/librtrad.so: undefined reference to `progrname`
../common/librtrad.so: undefined reference to `vv`
:
collect2: error: ld returned 1 exit status

This output you find for almost all modules/pograms, the only one that got
build seems cnt.

Please advise.

Denny

···

Am Dienstag, 23. Oktober 2012, 10:36:47 schrieb Guglielmetti, Robert:

Hi Denny,

Yeah there really isn't any documentation on the NREL site on how to
actually use the CMake build system in the Radiance source tree, yet. Pally
at IESve wrote up a great summary of her experience using CMake and posted
it here a couple/few months ago.

Sounds like you have CMake on your system. The quick bullet list of steps I
do is as follows:

1. create build directory in ray/
2. cd ray/build
3. cmake ..
4. ccmake .
4a. In the ccmake "gui", type 'c' to configure, fix any errors found
4b. Type 'g' to generate themakefiles; ccmake will then exit
5. make
if all goes well, then:
6. sudo make install

Lemme know if that helps.

- Rob

________________________________________
From: Denny [[email protected]]
Sent: Tuesday, October 23, 2012 9:10 AM
To: [email protected]
Subject: [Radiance-dev] compile radiance HEAD 3332 with cmake on command
   line / linux

Dear all,

I tried to compile radiance HEAD 3332 from source (snapshot) on an openSUSE
12.2 64bit box with cmake 2.8.9; gcc 4.7.1, but don't get a working version
of radiance.

As I couldn't find much documentation on the cmake build for radiance and I
haven't used cmake much, It would be good to get some guidance.

Here is what I did:

1. Untar src

/> tar xvf radiance-HEAD-ecd3332.tar.gz

2. change into directory and call cmake

/>cd radiance-HEAD-ecd3332

/>cmake src/

Everything looks good, except for the following warning:

CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower

if you wish to support older CMake versions for this project. For more

information run "cmake --help-policy CMP0000".

This warning is for project developers. Use -Wno-dev to suppress it.

3. Build binaries from source

/>make -i

4. Install

/>make install -i

Following things I noticed:

1. Build fails when not using -i with make, as there are many issues
regarding a missing Version.c file, like:

[ 37%] Built target genworm

[ 37%] Generating /src/rt/Version.c

CMake Error: Error processing file:/src/rt/create_version.cmake

make[2]: *** [/src/rt/Version.c] Error 1

make[1]: *** [rt/CMakeFiles/radiance.dir/all] Error 2

make: *** [all] Error 2

2. There is no build/ directory created when building that holds the
resulting binaries etc.

Questions:

1. Is there anything obvious, I should do differently?

2. How do I install executables etc. to /usr/ rather than /usr/local/ e.g
/usr/bin or /usr/share/radiance/ etc. without patching the sources/cmake
files?

Thanks for your help.

Denny

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev

Dear all,
when compiling with static libraries, I get a dependency error when the
program gets packaged for rpm:

file:
  src/util/trad.wsh:
contains
  #!/usr/local/bin/wish4.0

and therefor a dependency is automatically generated for it, which is not
allowed/possible.

Solution (if wish is still needed):
Replace the line with
  #!/usr/bin/wish

which will create a dependency a tk package meets.

Regards,

Denny

···

Am Dienstag, 23. Oktober 2012, 10:36:47 schrieb Guglielmetti, Robert:

Hi Denny,

Yeah there really isn't any documentation on the NREL site on how to
actually use the CMake build system in the Radiance source tree, yet. Pally
at IESve wrote up a great summary of her experience using CMake and posted
it here a couple/few months ago.

Sounds like you have CMake on your system. The quick bullet list of steps I
do is as follows:

1. create build directory in ray/
2. cd ray/build
3. cmake ..
4. ccmake .
4a. In the ccmake "gui", type 'c' to configure, fix any errors found
4b. Type 'g' to generate themakefiles; ccmake will then exit
5. make
if all goes well, then:
6. sudo make install

Lemme know if that helps.

- Rob

________________________________________
From: Denny [[email protected]]
Sent: Tuesday, October 23, 2012 9:10 AM
To: [email protected]
Subject: [Radiance-dev] compile radiance HEAD 3332 with cmake on command
   line / linux

Dear all,

I tried to compile radiance HEAD 3332 from source (snapshot) on an openSUSE
12.2 64bit box with cmake 2.8.9; gcc 4.7.1, but don't get a working version
of radiance.

As I couldn't find much documentation on the cmake build for radiance and I
haven't used cmake much, It would be good to get some guidance.

Here is what I did:

1. Untar src

/> tar xvf radiance-HEAD-ecd3332.tar.gz

2. change into directory and call cmake

/>cd radiance-HEAD-ecd3332

/>cmake src/

Everything looks good, except for the following warning:

CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower

if you wish to support older CMake versions for this project. For more

information run "cmake --help-policy CMP0000".

This warning is for project developers. Use -Wno-dev to suppress it.

3. Build binaries from source

/>make -i

4. Install

/>make install -i

Following things I noticed:

1. Build fails when not using -i with make, as there are many issues
regarding a missing Version.c file, like:

[ 37%] Built target genworm

[ 37%] Generating /src/rt/Version.c

CMake Error: Error processing file:/src/rt/create_version.cmake

make[2]: *** [/src/rt/Version.c] Error 1

make[1]: *** [rt/CMakeFiles/radiance.dir/all] Error 2

make: *** [all] Error 2

2. There is no build/ directory created when building that holds the
resulting binaries etc.

Questions:

1. Is there anything obvious, I should do differently?

2. How do I install executables etc. to /usr/ rather than /usr/local/ e.g
/usr/bin or /usr/share/radiance/ etc. without patching the sources/cmake
files?

Thanks for your help.

Denny

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev

Actually there are no CMake "scripts" in the source tree, merely CMake build system files. Due to dependencies on libtiff (and Qt for the fully cross-platform rvu), and of course CMake, there is slight brain pain in getting your personal system ready to build, but from there a little scripting skill is all you need to use the CMake system. Check it out:

This is the script that we call on our nightly test machines (this builds the project and runs the ctests, and relies on a Kitware git clone of the Radiance CVS repo):

#!/usr/bin/ruby

···

##############################################################################
# Build Radiance
##############################################################################

require 'pathname'
require 'fileutils'
require 'erb'
require 'socket'

##############################################################################
#Common Functions
def configure(rcmake,cmake,env)
  template_text = ''
  File.open(rcmake) { |f| template_text << f.read }
  template = ERB.new(template_text)

  FileUtils.mkdir_p(cmake.dirname)
  File.open(cmake,'w+') { |f| f << template.result(env) }
end

def run(cmake)
  build_config = ''
  verbose_cmd = ''
  if VERBOSE_OUTPUT
    verbose_cmd = '-VV'
  end
  if /mswin/.match(RUBY_PLATFORM)
    build_config = "-C \"Release\""
  end
  system("ctest #{verbose_cmd} #{build_config} -S #{cmake}")
end

def run_nightly(rcmake,cmake,env)
  configure(rcmake,cmake,env)
  run(cmake)
end

##############################################################################
# Script Variables
case Socket.gethostname

when "hooper-2.local"
  win_version = "none"
  site = "hooper"
  build_name_modifer = "OSX-10.8-Universal"
  dashroot = Pathname.new("/Users/rpg/repos/radiance_build/radiance/")
else
  win_version = "none"
  build_name_modifer = ""
end

script_dir = Pathname.new(__FILE__).dirname.realpath
clean_build = true
VERBOSE_OUTPUT = true
if /mswin/.match(RUBY_PLATFORM)
  dashroot = Pathname.new("C:/radiance_build/radiance/")
  generator = "Visual Studio 9 2008 Express"
else generator = "Unix Makefiles"
end
jobs = "2"
if /linux/.match(RUBY_PLATFORM)
  ENV['LC_CTYPE'] = 'en_US.UTF-8'
  ENV['LANG'] = 'en_US.UTF-8'
  display = ENV['DISPLAY']
  dashroot = Pathname.new("/home/bldadmin/radiance_build/radiance/")
elsif /darwin/.match(RUBY_PLATFORM)
  dashroot = Pathname.new("/rad/radiance_build/radiance/")
end

Dir.chdir(dashroot)
system("git pull")

source_directory = (dashroot).to_s
binary_directory = (dashroot + "build").to_s
radiance_build_dir = binary_directory
model = "Nightly"

run_nightly("#{script_dir}/radiance.rcmake",dashroot + "radiance.cmake",binding)

#EOF

...and this is the .rcmake file contents that I think Denny can get a lot of tips from:

CMAKE_MINIMUM_REQUIRED( VERSION 2.8.4 )
##############################################################################
# Build Radiance
##############################################################################
# Configuration variables to be set by the managing ruby script
#
# Path configuration for build and source directories
SET( CTEST_SOURCE_DIRECTORY "<%=source_directory%>" )
SET( CTEST_BINARY_DIRECTORY "<%=binary_directory%>" )
# generator
SET( generator "<%=generator%>" )
# win_version
SET( win_version "<%=win_version%>" )
# model
SET( model "<%=model%>" )

SET( CTEST_ENVIRONMENT "DISPLAY=<%=display%>" )

# clean_build
SET( clean_build <%=clean_build%> )
# jobs
SET( jobs "<%=jobs%>" )
# build name modifer
SET( build_name_modifer "<%=build_name_modifer%>" )
SET( radiance_build_dir "<%=radiance_build_dir%>" )
SET( site "<%=site%>" )

##############################################################################
# Project, Site, and Build name configuration
#SITE_NAME( SITE )
SET( CTEST_SITE <%=site%> )
SET( CTEST_BUILD_NAME "${CMAKE_SYSTEM_NAME}-${build_name_modifer}" )

###############################################################################
# Configure for CDash
SET( CTEST_PROJECT_NAME "Radiance" )
SET( CTEST_NIGHTLY_START_TIME "00:00:00 MST" )
SET( CTEST_DROP_METHOD "http" )
SET( CTEST_DROP_SITE "my.cdash.org" )
SET( CTEST_DROP_LOCATION "/submit.php?project=Radiance" )
SET( CTEST_DROP_SITE_CDASH TRUE )

###############################################################################
# Set the package type
# Can only have one package type
SET( UNIX_PACKAGE_NAME "all" )
SET( MSVC_PACKAGE_NAME "ALL_BUILD" )

###############################################################################
# Build type
# Configures CTest to use the correct build command depending on platform

#### Linux and Mac
IF( ${generator} STREQUAL "Unix Makefiles" )
  SET( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
  SET( CTEST_BUILD_COMMAND "make ${UNIX_PACKAGE_NAME} -j${jobs}" )
#### Windows - ${win_version} needs to be set if building on windows 7
# Visual Studio 2008
ELSEIF( ${generator} STREQUAL "Visual Studio 9 2008" )
  SET( CTEST_CMAKE_GENERATOR "Visual Studio 9 2008" )
  SET( MSVC_IS_EXPRESS "OFF" )
  IF( ${win_version} STREQUAL "7" )
    SET( CTEST_BUILD_COMMAND "\"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.com\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
  ELSE()
    SET( CTEST_BUILD_COMMAND "\"C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.com\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
  ENDIF( ${win_version} STREQUAL "7" )
# Visual Studio Express 2008
ELSEIF( ${generator} STREQUAL "Visual Studio 9 2008 Express" )
  SET( CTEST_CMAKE_GENERATOR "Visual Studio 9 2008" )
  SET( MSVC_IS_EXPRESS "ON" )
  IF( ${win_version} STREQUAL "7" )
    SET( CTEST_BUILD_COMMAND "\"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\vcexpress.exe\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
  ELSE()
    SET( CTEST_BUILD_COMMAND "\"C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\vcexpress.exe\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
  ENDIF( ${win_version} STREQUAL "7" )
# Visual Studio 10
ELSEIF( ${generator} STREQUAL "Visual Studio 10" )
  SET( CTEST_CMAKE_GENERATOR "Visual Studio 10" )
  SET( MSVC_IS_EXPRESS "OFF" )
  SET( CTEST_BUILD_COMMAND "\"C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.com\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
# Visual Studio Express 10
ELSEIF( ${generator} STREQUAL "Visual Studio 10 Express" )
  SET( CTEST_CMAKE_GENERATOR "Visual Studio 10" )
  SET( MSVC_IS_EXPRESS "ON" )
  SET( CTEST_BUILD_COMMAND "\"C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\vcexpress.exe\" Radiance.sln /build Release /project ${MSVC_PACKAGE_NAME}" )
ENDIF()

###############################################################################
# Start with a completely empty binary directory?
IF( clean_build )
  CTEST_EMPTY_BINARY_DIRECTORY( "${CTEST_BINARY_DIRECTORY}" )
ENDIF()

###############################################################################
# Start
message("CTest: Starting ${model} in ${CTEST_BINARY_DIRECTORY}")
ctest_start("${model}" "${CTEST_SOURCE_DIRECTORY}" "${CTEST_BINARY_DIRECTORY}" )

###############################################################################
# Set the initial cache and other model specific variables

SET( INITIAL_CACHE "
# BUILD_TESTING:BOOL=ON
  MSVC_IS_EXPRESS:BOOL=${MSVC_IS_EXPRESS}
  CTEST_SITE:STRING=<%=site%>
")

# Mac specific cache stuff
IF( APPLE )
  SET( INITIAL_CACHE "
     ${INITIAL_CACHE}
     CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5
     CMAKE_OSX_SYSROOT:STRING=/Developer/SDKs/MacOSX10.5.sdk
     CMAKE_OSX_ARCHITECTURES:STRING=i386;x86_64
  ")
ENDIF()

###############################################################################
# If binary directory does not exist, we create it and add the initial cache
# If it does exist we just update the svn version
IF( NOT EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
  # Write initial cache.
  file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${INITIAL_CACHE}")
ELSE()
  file(READ "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" CACHE_TEXT)
  string(REGEX REPLACE "CMAKE_VERSION_BUILD:STRING=[A-Za-z0-9]*"
        "CMAKE_VERSION_BUILD:STRING=${REPO_VERSION}"
        NEW_CACHE_TEXT "${CACHE_TEXT}" )
  file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${NEW_CACHE_TEXT}")
ENDIF()

###############################################################################
# Configure
message("CTest: Configuring ${model}")
ctest_configure( BUILD "${CTEST_BINARY_DIRECTORY}" SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res )
IF(NOT res EQUAL 0 )
  message("CTest: Configure failed")
ENDIF()

###############################################################################
# Build
message("CTest: Building ${model}")
ctest_build( BUILD "${CTEST_BINARY_DIRECTORY}" NUMBER_ERRORS res )
IF(NOT res EQUAL 0 )
  message("CTest: Build failed")
ELSE()
  message("CTest: Build succeeded")
ENDIF()

###############################################################################
# Test
message("CTest: Testing ${model}")
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res )

###############################################################################
# Submit
message("CTest: Submitting results to CDash")
ctest_submit(RETURN_VALUE res )

# EOF

This is an entirely automated process, just a cron job. No reason why you couldn't request a "make package", here. I know that CMake supports the creation of RPMs too, I'm just not familiar with the specifics.

- Rob