Quantcast

Problem with override file ...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem with override file ...

CMake mailing list
Using the following override file results in the try_compile failing for
both the C compiler and the C++ compiler. The output shows that the
override file is being processed multiple times. The first time it is
processed, the variable PARAM is 'set' as specified on the CMake command
line. However, subsequent processing of the file shows that PARAM is not
'set' and results in the 'bogus-option' being added to the compiler
command line. This, of course, results in the try_compile's failing.

message(STATUS "Processing override_compiler_flags.cmake ...")

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    if(PARAM STREQUAL "set")
        message(AUTHOR_WARNING "PARAM is 'set' ...")
        add_definitions("-DPARAM=1")
    else()
        message(AUTHOR_WARNING "PARAM is not 'set' ...")
        add_definitions("--bogus-option")
    endif()
endif()

The CMake process is initiated with the following command line.

$ cmake -DPARAM=set ..

And, usage of the override file is set with the following before the
project is defined.

set(CMAKE_USER_MAKE_RULES_OVERRIDE
${CMAKE_CURRENT_SOURCE_DIR}/override_compiler_flags.cmake)

I have attached the output of the CMake run as well.

Is this a bug in that subsequent processing of the override file is not
using the cached value of PARAM?
Or, is there something wrong with the override file itself?

Thanks!

Mike


--

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

cmake-output.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with override file ...

CMake mailing list
I found that changing the add_definitions lines to set(CMAKE_C_FLAGS_INIT ...) or set(CMAKE_CXX_FLAGS_INIT ...) resolved the issue. I have not found documentation anywhere that says "this is how it must be done".

So, is this the expected behavior when using add_definitions in an override file?

Mike


On 2/8/2017 11:50 AM, Michael Burns via CMake wrote:
Using the following override file results in the try_compile failing for
both the C compiler and the C++ compiler. The output shows that the
override file is being processed multiple times. The first time it is
processed, the variable PARAM is 'set' as specified on the CMake command
line. However, subsequent processing of the file shows that PARAM is not
'set' and results in the 'bogus-option' being added to the compiler
command line. This, of course, results in the try_compile's failing.

message(STATUS "Processing override_compiler_flags.cmake ...")

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    if(PARAM STREQUAL "set")
        message(AUTHOR_WARNING "PARAM is 'set' ...")
        add_definitions("-DPARAM=1")
    else()
        message(AUTHOR_WARNING "PARAM is not 'set' ...")
        add_definitions("--bogus-option")
    endif()
endif()

The CMake process is initiated with the following command line.

$ cmake -DPARAM=set ..

And, usage of the override file is set with the following before the
project is defined.

set(CMAKE_USER_MAKE_RULES_OVERRIDE
${CMAKE_CURRENT_SOURCE_DIR}/override_compiler_flags.cmake)

I have attached the output of the CMake run as well.

Is this a bug in that subsequent processing of the override file is not
using the cached value of PARAM?
Or, is there something wrong with the override file itself?

Thanks!

Mike





--

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
Loading...