Hi,

> Is it possible to set a compiler flags only if compiler is MinGW (that
> means these flags wouldn't be set on MSVC).
to target specific compilers you can make use of CMAKE_CXX_COMPILER_ID.

In my projects I usually include compiler specific settings like this:

foreach(_base
    ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}
    ${CMAKE_CXX_COMPILER_ID})
    set(_file ${CMAKE_SOURCE_DIR}/cmake/compilers/${_base}.cmake)
    if(EXISTS ${_file})
        include(${_file})
        break()
    endif()
endforeach()

… and in ${CMAKE_SOURCE_DIR}/cmake/compilers/ I keep the target compiler
specific settings in Clang.cmake, GNU.cmake, MSVC.cmake and MinGW.cmake.

For normal use cases this works fine.

With kind regards,
Daniel


-- 

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