[CMake] PROJECT() and its role

Kishore, Jonnalagadda (IE10) Kishore.Jonnalagadda at honeywell.com
Mon Mar 26 11:05:06 EST 2007


I would really appreciate anyone who can throw more light to explain the
role of the PROJECT command.

Here is why. I have a CMakeLists.txt in top level source tree and it
contains:

MESSAGE("CMAKE_C_LINK_EXECUTABLE = ${CMAKE_C_LINK_EXECUTABLE}
		 FLAGS = ${FLAGS}
		 CMAKE_C_LINK_FLAGS = ${CMAKE_C_LINK_FLAGS}
		 LINK_FLAGS = ${LINK_FLAGS}
		 LINK_LIBRARIES = ${LINK_LIBRARIES}")
PROJECT(myProj)
MESSAGE("CMAKE_C_LINK_EXECUTABLE = ${CMAKE_C_LINK_EXECUTABLE}
		 FLAGS = ${FLAGS}
		 CMAKE_C_LINK_FLAGS = ${CMAKE_C_LINK_FLAGS}
		 LINK_FLAGS = ${LINK_FLAGS}
		 LINK_LIBRARIES = ${LINK_LIBRARIES}")

At the point where I set cross-compiler (in a sub directory) if I set
CMAKE_C_LINK_EXECUTABLE like this:

SET(CMAKE_C_LINK_EXECUTABLE  "<CMAKE_C_COMPILER> <FLAGS>
<CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET>
<LINK_LIBRARIES>")

I get the following output:

CMAKE_C_LINK_EXECUTABLE = <CMAKE_C_COMPILER> <FLAGS>
<CMAKE_C_LINK_FLAGS> <LINK_
FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>
                 FLAGS =
                 CMAKE_C_LINK_FLAGS =
                 LINK_FLAGS =
                 LINK_LIBRARIES =
CMAKE_C_LINK_EXECUTABLE = <CMAKE_C_COMPILER> <FLAGS>
<CMAKE_C_LINK_FLAGS> <LINK_
FLAGS> <OBJECTS>  -o <TARGET>
-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,-
-minor-image-version,<TARGET_VERSION_MINOR> <LINK_LIBRARIES>
                 FLAGS =
                 CMAKE_C_LINK_FLAGS =
                 LINK_FLAGS =
                 LINK_LIBRARIES =

I do not want the "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,-
-minor-image-version,<TARGET_VERSION_MINOR>" flags. If I do the set
operation after declaring project, it works as expected. I cannot remove
the project command because if I do that for some reason cmake won't
take my cross-compiler.

How can I avoid it system wide? For the sake of cross-compiling and
variation between linkers, I want to set CMAKE_C_LINK_EXECUTABLE along
with the compiler settings and I need to declare project after setting
the cross-compiler or it won't take effect.

Warm regards,
Kishore


More information about the CMake mailing list