Tutorial. More things that might confuse a stupid person

Another mistake a stupid person might make (don’t ask me how I know) during the tutorial, would be to initially

cd Step1_build
cmake ../Step1/CMakeLists.txt

which creates the make file and other shiz in the Step1 folder instead of the Step1_build folder, inadvertently polluting the source folder with build artefacts.


Reading the code in cmProjectCommand.cxx I notice it is written in a complicated way in order to accept a more general grammar for project() than the documentation indicates: the clauses after the project name can be in any order, possibly with languages interspersed, so this is accepted:

project(Tutorial                                                                                      
    LANGUAGES C ASM                                                                                   
    HOMEPAGE_URL cmake.org                                                                            
    DESCRIPTION "cmake tutorial"                                                                      
    CXX                                                                                               
    VERSION 1.0                                                                                       
    )     

Then someone might add OBJC as another language

project(Tutorial                                                                                      
    LANGUAGES C ASM                                                                                   
    HOMEPAGE_URL cmake.org                                                                            
    DESCRIPTION "cmake tutorial"                                                                      
    CXX                                                                                               
    OBJC
    VERSION 1.0                                                                                       
    )     

and then run

cmake ../Step1

again from the Step1_build directory. No error, cmake saying “Check for working OBJC compiler: /usr/bin/clang - skipped)”.
But then when I was still in Step1_build I cleaned out cmake’s previous workings and ran a fresh cmake

rm -r *
cmake ../Step1

and got the error

The Objective-C compiler                                                                            
                                                                                                     
    "/usr/bin/cc"                                                                                     
                                                                                                      
  is not able to compile a simple test program.

I don’t have a working OBJC compiler so this is as expected (AFAIK since I was unable to compile hello world .m)

I believe this is from the tutorial.zip layout? IIRC, Step1 is a top-level directory in that case. Wording may need to adapt to consider this distribution mechanism.

It is interesting that CXX is not in the LANGUAGES list but provided separately. Not that I suspect it will fix anything here, but just something I noticed.

Cc: @betsy.mcphail

It’s not the directory structure, it was a mistake I made running cmake ../Step1/CMakeLists.txt instead of cmake ../Step1 which the tutorial correctly told me to do (i.e. I gave it the CMakeLists.txt file instead of the directory). I would have hoped cmake would have told me off for trying to build in the source directory/tree, (by this means or by any other).

Yep you can have CXX out of the languages list and the current code will recognize it (from my reading of the source - I haven’t run it). It appears cmake thinks anything not in the format of an option keyword followed by its parameter(s) is a language, which can to seen by adding something meaningless like WIBBLE (say after CXX) and it will complain it does not understand language WIBBLE. I suspect this is a hang over from the old syntax where the languages were listed without the preceding LANGUAGES keyword.

Ah. I think the command line parsing could probably detect this. @robert.maynard?

Yep. I was more curious at the mixing of the new signature and the old patterns.