[CMake] How to rename the resulting Makefile.

Eric Noulard eric.noulard at gmail.com
Tue Oct 12 11:25:17 EDT 2010


2010/10/12 william.crocker at analog.com <william.crocker at analog.com>:
>
>>>
>>> [ elided ]
>>>
>>> So, is there a command I can place in my CMakeLists.txt files
>>> which will cause them to produce a file named xyz.make (let's say)
>>> instead of Makefile.
>>>
>>> Thanks in advance.
>>
>> Use out of source builds, and there should be no-conflict.  There is no
>> way to rename the makefiles.
>>
>> mkdir build
>> cd build.
>> cmake ../path/to/source
>> make
>>
>
> Okay. I see that OOS builds can create Makefiles without clobbering
> my existing Makefile, but then I do not have convenient access to my
> Makefiles
> and the convenience targets they contain from the OOS dir.

Yes you do:

add_custom_target(save
                             COMMAND ${CMAKE_MAKE_PROGRAM} save
                             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                             COMMENT "Home brewed make save target")


but I wouldn't do that.

> I still think Qt/qmake was right in providing the ability to change
> the name of the Makefile. Before I discovered that, I could not use
> the qmake system.

I agree that it would be a good feature to be able to change the name
of generated
makefiles, but if you dig the ML you'll see that **after discussion**
there is not
so many **useful** cases to do that.

> Below is typical of what my Makefile contains:
> Convenience targets (all in one place) and a call to the makefile
> created by qmake (myapp.make). In this way qmake does not have to solve
> the whole problem, just contribute a part of the solution.

But you home-brewed Makefile is not cross-platform which is one of the
primary target for using CMake :-]

Moreover you have to described you lib and executable target names
in two places (CMakeLists.txt and home made Makefile) which
opens a window for inconsistency.

> ------------------
>
> myapp : always
>        make -f myapp.make
>
> save : always
>        mkdir -p save_dir
>        /bin/cp -pr *.h *.cc *.lyx *.xml *.xsl *.txt *.css Makefile save_dir

You can use add_custom_target and basic CMake scripting for doing just the same.
Look at

file(xxxx ...) commands

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list