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 <r...@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.c...@kitware.com]
> Sent: Tuesday, November 13, 2012 5:40 PM
> To: Marshall, Rob
> Cc: cmake@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 <r...@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
--

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

Reply via email to