[CMake] install (CODE ... is not being invoked
David Cole
david.cole at kitware.com
Thu Nov 15 18:03:05 EST 2012
You can use:
BUILD_COMMAND make $ENV{INSTALL_TO_ARTIFACTS} -f Makefile
but that will substitute the value of the environment variable at
CMake-configure time.
The only way I know of to get a build-time or install-time reading of
an environment variable is to write a script that is executed as the
build or install command, and then have the script read the
environment when it is invoked.
Is there something unclear about this?
What is it that sets the environment, and what changes it? Why are you
trying to do this, when you can just say "make install"? I don't
understand why you want the command itself to use a reference to an
environment variable.
On Thu, Nov 15, 2012 at 3:35 PM, Marshall, Rob <robm at qti.qualcomm.com> wrote:
> I think the issue I am seeing is that when my cmake ExternalProject_Add build command looks like this:
>
> BUILD_COMMAND make $INSTALL_TO_ARTIFACTS -f Makefile
>
> when the statement is invoked by execute_process(see below), $INSTALL_TO_ARTIFACTS is not evaluated as in would be on the bash shell. So I see the error message below... Is there some way to format the BUILD_COMMAND so that is interpreted when the command is run?
>
> Thanks,
> Rob
>
> make[3]: *** No rule to make target `$INSTALL_TO_ARTIFACTS'. Stop.
>
> set(command "make; $INSTALL_TO_ARTIFACT; -f; Makefile.libcxx") execute_process(
> COMMAND ${command}
> RESULT_VARIABLE result
> OUTPUT_FILE "build-out.log"
> ERROR_FILE "build-err.log"
> )
>
> -----Original Message-----
> From: David Cole [mailto:david.cole at kitware.com]
> Sent: Wednesday, November 14, 2012 11:17 AM
> To: Marshall, Rob
> Cc: cmake at cmake.org
> Subject: Re: [CMake] install (CODE ... is not being invoked
>
> If you need to set build time ENV vars, how about this?
>
> # build.cmake:
> set(ENV{WEBSOCKETPP_INSTALL_TO_ARTIFACTS} "install") execute_process(COMMAND make -f Makefile $ENV{WEBSOCKETPP_INSTALL_TO_ARTIFACTS})
>
> and then:
>
> ExternalProject_Add( ...
> BUILD_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/build.cmake
> ...
> )
>
> That's the only presently reasonable way to set ENV vars during an ExternalProject build step.
>
>
> HTH,
> David
>
>
> On Wed, Nov 14, 2012 at 2:08 PM, Marshall, Rob <robm at qti.qualcomm.com> wrote:
>> Thanks David,
>>
>> I see that install (CODE... is working.
>>
>> But I am trying use the ENV var to set whether or not an
>> ExternalProject_Add BUILD_COMMAND is called with "install" or not but when I run "make install" on the snippet below I see a make error.
>>
>> install(CODE "set( ENV{WEBSOCKETPP_INSTALL_TO_ARTIFACTS} \"install\"
>> )" )
>>
>> ExternalProject_Add(
>> BUILD_COMMAND make -f Makefile $WEBSOCKETPP_INSTALL_TO_ARTIFACTS
>>
>>
>> make[3]: *** No rule to make target `$WEBSOCKETPP_INSTALL_TO_ARTIFACTS'. Stop.
>>
>> Is this possible to do this? I am thinking I don't have the double or single quotes right for bash to do this?
>>
>> I would hope to expect that the BUILD_COMMAND is executed as
>>
>> make -f Makefile install
>>
>> when "make install" is invoked on the command line.
>>
>> Thanks,
>> Rob
>>
>> ________________________________________
>> From: David Cole [david.cole at kitware.com]
>> Sent: Tuesday, November 13, 2012 5:40 PM
>> To: Marshall, Rob
>> Cc: cmake at cmake.org
>> Subject: Re: [CMake] install (CODE ... is not being invoked
>>
>> If I copy/paste your code into a stand-alone CMakeLists.txt file, and
>> run CMake 2.8.10.1 on my Mac with it, I get the expected output:
>>
>> "Sample install message." appears during "make install" after you do a
>> "cmake" and "make" first...
>>
>> INSTALL_TO_ARTIFACTS is empty during the cmake configure stage... It
>> is only set when the install script is running at "make install" time.
>>
>>
>> HTH,
>> David
>>
>>
>> DETAILS:
>> ==========================
>>
>> $ cat CMakeLists.txt
>> install(CODE "set( INSTALL_TO_ARTIFACTS install )" ) install(CODE
>> "message(\"Sample install message.\")") message ("
>> INSTALL_TO_ARTIFACTS is: ${INSTALL_TO_ARTIFACTS}" )
>>
>> $ mkdir build
>>
>> $ cd build
>>
>> $ cmake ..
>> -- The C compiler identification is GNU 4.2.1
>> -- The CXX compiler identification is GNU 4.2.1
>> -- Checking whether C compiler has -isysroot
>> -- Checking whether C compiler has -isysroot - yes
>> -- Checking whether C compiler supports OSX deployment target flag
>> -- Checking whether C compiler supports OSX deployment target flag -
>> yes
>> -- Check for working C compiler: /usr/bin/cc
>> -- Check for working C compiler: /usr/bin/cc -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Checking whether CXX compiler has -isysroot
>> -- Checking whether CXX compiler has -isysroot - yes
>> -- Checking whether CXX compiler supports OSX deployment target flag
>> -- Checking whether CXX compiler supports OSX deployment target flag -
>> yes
>> -- Check for working CXX compiler: /usr/bin/c++
>> -- Check for working CXX compiler: /usr/bin/c++ -- works
>> -- Detecting CXX compiler ABI info
>> -- Detecting CXX compiler ABI info - done INSTALL_TO_ARTIFACTS is:
>> CMake Warning (dev) in CMakeLists.txt:
>> No cmake_minimum_required command is present. A line of code such
>> as
>>
>> cmake_minimum_required(VERSION 2.8)
>>
>> should be added at the top of the file. The version specified may be lower
>> if you wish to support older CMake versions for this project. For more
>> information run "cmake --help-policy CMP0000".
>> This warning is for project developers. Use -Wno-dev to suppress it.
>>
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: /Users/davidcole/K/tmp5/build
>>
>> $ make
>>
>> $ make install
>> Install the project...
>> -- Install configuration: ""
>> Sample install message.
>>
>>
>>
>> On Tue, Nov 13, 2012 at 8:23 PM, Marshall, Rob <robm at qti.qualcomm.com> wrote:
>>> Hi,
>>>
>>> I am trying to use install (CODE) with my cmake script when I invoke
>>> "make install" on the command line but when I run the "make install"
>>> on the following code
>>>
>>> install(CODE "set( INSTALL_TO_ARTIFACTS install )" ) install(CODE
>>> "message(\"Sample install message.\")") message ("
>>> INSTALL_TO_ARTIFACTS is: ${INSTALL_TO_ARTIFACTS}" )
>>>
>>>
>>> INSTALL_TO_ARTIFACTS is not set and "Sample install message." does
>>> not display I only see "INSTALL_TO_ARTIFACTS is: " in the console
>>> window
>>>
>>> Is there some additional setting required to make this work?
>>>
>>> Thanks,
>>> Rob
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list