[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] CMAKE_BUILD_TYPE and exact control of compiler options
From: Dan Liew <dan () su-root ! co ! uk>
Date: 2015-10-13 10:10:01
Message-ID: CAJ7DczHXW5SvjtTxXqT0tWG8q3Y965kdM+1h+teHfoVnUkH4Gw () mail ! gmail ! com
[Download RAW message or body]
Hi,
> - If not, what is the best/official way to get exact control over the compiler
> and linker options used?
I had to do something similar recently where I didn't want
``-DNDEBUG`` to be in any of the configurations.
I used ``CMAKE_USER_MAKE_RULES_OVERRIDE `` to set the path to file
containing overrides, this must be set before calling ``project()``
```
set(CMAKE_USER_MAKE_RULES_OVERRIDE
${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flags_override.cmake)
project(ABC C)
```
The contents of ``c_flags_override.cmake`` looks like this
```
if (("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") OR
("${CMAKE_C_COMPILER_ID}" MATCHES "GNU"))
# Taken from Modules/Compiler/GNU.cmake but -DNDEBUG is removed
set(CMAKE_C_FLAGS_INIT "")
set(CMAKE_C_FLAGS_DEBUG_INIT "-g")
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os")
set(CMAKE_C_FLAGS_RELEASE_INIT "-O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
else()
message(FATAL_ERROR "Overrides not set for compiler ${CMAKE_C_COMPILER_ID}")
endif()
```
I'm not sure if this is really the correct route to go down though for
your use case.
Dan.
--
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic