On Dec 11, 2015, at 2:44 AM, CHEVRIER, Marc <[email protected]> wrote:

> With CMake, you can control compilation and link flags with the following 
> environment variables:
> CC: specify C compiler
> CFLAGS: C compiler flags
> CXX: specify C++ compiler
> CXXFLAGS: C++ compiler flags
> LDFLAGS: linker flags
> And to finish you can overload make command for generation using 
> CMAKE_COMMAND option of ExternalProject_Add:
> CMAKE_CMMAND “${CMAKE_COMMAND}” -E env CXX=${CMAKE_CXX_COMPILER} LDFLAGS=“…” 
> “${CMAKE_COMMAND}”

This has probably been mentioned before, but it would be very useful if the 
output generators would take environment variable overrides into account.  This 
is particularly useful during adhoc development testing where one wants to 
override build flags, or two-stage compilation, or when the generated output is 
unhelpful for a given user’s configuration, etc.  It’s also a feature lost for 
projects converting from Autotools-generated Makefile builds.  An example, 
two-stage compilation might be something like:

CC=icc cmake .. 
make CFLAGS=“-fast -O3 -prof_gen /path/to/filename”
# run some tools
make CFLAGS=“-fast -O3 prof_use /path/to/filename”

Gets even more complicated if one only wants to instrument one/few files down 
in some subdir.  Editing flags.make doesn’t really work well in that situation. 
 Editing a CMakeLists.txt property for those few files is also particularly 
inconvenient when re-running CMake takes several minutes and/or the build 
change is merely exploratory development.

Apologies if there is already a way to do this now.  Last I looked a couple 
years ago, there was not and the docs on CMAKE_C_COMPILER seem to indicate this 
is still not possible.

Cheers!
Sean

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to