[CMake] add_target_properties( tgt COMPILE_FLAGS_${CONF} "abc" )
Leek, Jim
leek2 at llnl.gov
Tue Jun 25 18:39:53 EDT 2013
I was just messing around with this yesterday. On minGW I had to pass the link flag -static-libgcc to my binary. There were two ways to do this:
1) To add a flag to all link lines:
Shared Libraries:
SET (CMAKE_SHARED_LINKER_FLAGS "abc"
CACHE STRING "Flags used by the linker during the creation of dll's.")
module linker flags:
SET (CMAKE_MODULE_LINKER_FLAGS "abc"
CACHE STRING "Flags used by the linker during the creation of modules.")
binary linker flags:
SET (CMAKE_EXE_LINKER_FLAGS "abc"
CACHE STRING "Flags used by the linker during the creation of binaries.")
2) To add a flag to just a single target:
SET_TARGET_PROPERTIES( <target name>
PROPERTIES
LINK_FLAGS "abc")
If just used if statement to decide if how the link flags should be set. There may be a better way to do that.
To see how to do configuration based compile flags, see this page:
http://www.cmake.org/Wiki/CMake_Useful_Variables
I added a TESTING build type, and all I had to do was define these variables:
SET(CMAKE_CXX_FLAGS_TESTING "-mfpmath=sse -msse2")
SET(CMAKE_C_FLAGS_TESTING "-mfpmath=sse -msse2")
SET(CMAKE_Fortran_FLAGS_TESTING "-mfpmath=sse -msse2")
-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Miller Henry
Sent: Tuesday, June 25, 2013 8:41 AM
To: "Sören Textor [Ditec-GmbH]"; cmake at cmake.org
Subject: Re: [CMake] add_target_properties( tgt COMPILE_FLAGS_${CONF} "abc" )
TARGET_LINK_LIBRARIES(${tgt} stdc++)
Should do the trick
-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of "Sören Textor [Ditec-GmbH]"
Sent: Tuesday, June 25, 2013 10:15 AM
To: cmake at cmake.org
Subject: [CMake] add_target_properties( tgt COMPILE_FLAGS_${CONF} "abc" )
Hello
Is it meanwhile possible to add configuration specfic compiler flags analouge to link flags?
add_target_properties( ${tgt} COMPILE_FLAGS_${CONF} "abc" )
add_target_properties( ${tgt} LINK_FLAGS_${CONF} "abc" )
Best regards
SirAnn
--
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
More information about the CMake
mailing list