[CMake] about the required project label...

J Decker d3ck0r at gmail.com
Sat Sep 18 03:18:42 EDT 2010


On Sat, Sep 18, 2010 at 12:00 AM, J Decker <d3ck0r at gmail.com> wrote:
> I have a small cmake script I include at start of several projects.  I
> define some things like where includes and libraries are for the
> common libraries. This has worked well for the few extensions that I
> did, because their root cmakelists.txt had no project.  Some things
> like CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT and
> CMAKE_COMPILER_IS_GNUCC *are set* as valid if you have a
> cmakelists.txt with no projects, and only add_subdirectory()s.  They
> are not set if you reference them before you define an initial
> project.
>
>    1) define a PROJECT( Unused_project_name ) in CMakeDefs referenced
> earlier.
>        a) This works 50% of the time... becuase since there are other
> cmake users out there that know you shouldn't do anything before a
> project label, they will have set a project before doing the include,
> and then my project will interfere and not be the target project they
> think they're using.
>        b) ? nothing good here I suppse
>    2) err (I don't understand why this works) but move include to the
> end of the file?... and therefore within one of the projects  (this
> particular family has 4 projects all in the same directory...) but it
> works fine to include it at the end.


Dangit really wish I would follow through further somtimes solution 2)
did not work.  I NEED to include those definitions at the beginning,
or the target_link_libraries don't have the libraries....>

and in that include, I NEED CMAKE_COMPILER_IS_GNUCC to be set
correctly... so what then, break everything into a proper root project
that adds all the related projects?  Is there a variation of
add_subdirectory that will take a filename?

I guess it's just add a PROJECT above the include... but after set_property....

There's probably a really good reason why this can't be better
protected with warnings around using things that work without ANY
projects, but won't work before PROJECT in a cmake script.


More information about the CMake mailing list