[CMake] Multiple PROJECT() statements
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Mon Nov 9 17:03:37 EST 2009
On 2009-11-09 12:52-0800 Phil Smith wrote:
> I'm working with a CMakeLists.txt file I didn't create, so this may be a dumb question, but that won't stop me from asking it!
>
> We're using a System z cross-compiler called Dignus. I have it all working, but when we merged back into the SVN trunk, the PROJECT() statement became an issue.
>
> CMake is invoked thus:
> cmake -DCMAKE_TOOLCHAIN_FILE:string=".\zosport.cmake" -G"Unix Makefiles" .\
>
> zosport.cmake contains (among other things):
> SET(CMAKE_SYSTEM_NAME "IBM_ZOS")
>
> Through some MESSAGE() statements, I've convinced myself that zosport.cmake gets loaded by the PROJECT() statement. BUT I need to customize the PROJECT() statement based on the environment. What I have now is:
>
> project(vtk-core C)
> if(CMAKE_SYSTEM_NAME STREQUAL "IBM_ZOS")
> project(vtk-core C ASM_DIGNUS)
> endif()
>
> This seems to work OK, but I wasn't sure if it was evil for some reason, or if there was a preferred approach.
I would suggest using enable_language instead, e.g.,:
project(vtk-core C)
if(CMAKE_SYSTEM_NAME STREQUAL "IBM_ZOS")
enable_language(ASM_DIGNUS)
endif()
Even if running two project commands works in all cases, this
enable_language alternative is cleaner in the sense that it does not repeat
logic (such as enabling C).
Alan
P.S. There are no dumb questions. :-)
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the CMake
mailing list