[CMake] Parsing command line arguments from the make

Matějů Miroslav, Ing. Mateju.Miroslav at azd.cz
Tue Apr 5 04:36:10 EDT 2016


Hi Fedja,

As far as I know, the Makefiles generated  from CMake cannot contain decisions. CMake supports several output types aside from Makefiles and some of them probably don’t support decisions. However, you could supply these arguments within CMake call using -D option. For example
    cmake -DENV=VERSION_2 <source_or_binary_directory>
creates a CMake variable just like
    set(ENV "VERSION_2" CACHE)
in the CMake source file.

As you’ve mentioned already, you can access environment variables using $ENV{variable} syntax in CMake.

Hope this helps.

Miroslav

From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Fedja Jeleskovic
Sent: Friday, April 01, 2016 8:08 PM
To: cmake at cmake.org
Subject: [CMake] Parsing command line arguments from the make

Since I am converting existing makefile project to use cmake instead I need to accept values that come from command line which looks like this:
VARIABLE_NAME="/home/user/project" make ENV=VERSION_2

First one is used like this:
include $(VARIABLE_NAME)/Makefile.include

Second one has this code that triggers different paths later:
ifneq ($(ENV),)
DEPLOYMENT_VERSION=$(ENV)
endif

How do I do this in cmake?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160405/c4ad4693/attachment.html>


More information about the CMake mailing list