[CMake] Question about if/else in Cmake

Alexander Neundorf a.neundorf-work at gmx.net
Tue Mar 10 15:56:17 EDT 2009


On Tuesday 10 March 2009, Sascha 'saigkill' Manns wrote:
> Hello Mates,
>
> i'm Sascha Manns from Germany. I'm new to the List, and i hope that i
> can learn more about CMake.
> Actually i'm building for the openSUSE Build Service an Package called
> "freeremote".
>
> The Package has the following in the CMakeLists.txt:
> SET( CONFIGFILE_PATH ${PREFIX}/etc/freeremoted CACHE PATH "Path find
> config file" FORCE )
> SET( MODULEFILE_PATH ${PREFIX}/lib/freeremoted CACHE PATH "Path find
> module file" FORCE )
>
> That means, that the Package is builded into the Userspace.
>
> So i modified it to use /etc and /usr/lib as Destination.
>
> SET( CONFIGFILE_PATH /etc/freeremoted CACHE PATH "Path find config
> file" FORCE )
> SET( MODULEFILE_PATH /usr/lib CACHE PATH "Path find module file" FORCE)
>
> But this only runs for i586/i686 but not for x86_64.
>
> It is possible to make:
>
>

There are different things you can do:

You can test the variable ${CMAKE_SIZEOF_VOID_P}, if it is equal to 8, you are 
on a 64 bit system and may want to use lib64.

Or you could test whether e.g. /usr/lib64 exists, and if so, also use lib64.

Or you can just make it an option:

option(USE_LIB64_DIR "Enable this option to use lib64 instead of lib/" FALSE)

And then in all cases set a variable like LIB_INSTALL_DIR accordingly.

Does that help ?

Alex


More information about the CMake mailing list