[CMake] add_target_properties( tgt COMPILE_FLAGS_${CONF} "abc" )
Leek, Jim
leek2 at llnl.gov
Wed Jun 26 07:41:28 EDT 2013
Sorry, I don't have a nice clean answer like that for you. I'm too new at cmake I guess. I would just fall back on if statements.
If(CMAKE_BUILD_TYPE MATCHES Debug)
set_target_properties( ${tgt} COMPILE_FLAGS_DEBUG "/GA" )
elseif(CMAKE_BUILD_TYPE MATCHES Release)
...
endif()
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of "Sören Textor [Ditec-GmbH]"
Sent: Wednesday, June 26, 2013 12:28 AM
To: cmake at cmake.org
Subject: Re: [CMake] add_target_properties( tgt COMPILE_FLAGS_${CONF} "abc" )
sorry my fault.
add_target_properties is a helper macro that I wrote.
Finally this is what I need:
set_target_properties( ${tgt} COMPILE_FLAGS_DEBUG "/GA" )
set_target_properties( ${tgt} COMPILE_FLAGS_RELEASE "/GB" )
set_target_properties( ${tgt} COMPILE_FLAGS_MYCONFIG1 "/GC" )
set_target_properties( ${tgt} COMPILE_FLAGS_MYCONFIG1 "/GD" )
And this is what already works:
set_target_properties( ${tgt} LINK_FLAGS_DEBUG "/Libpath:xxx1" )
set_target_properties( ${tgt} LINK_FLAGS_RELEASE "/Libpath:xxx2" )
set_target_properties( ${tgt} LINK_FLAGS_MYCONFIG1 "/Libpath:xxx3" )
set_target_properties( ${tgt} LINK_FLAGS_MYCONFIG1 "/Libpath:xxx4" )
Am 26.06.2013 09:07, schrieb "Sören Textor [Ditec-GmbH]":
okay, it seems that there's a missunderstanding.
The thing I want to do is this:
add_target_properties( ${tgt} COMPILE_FLAGS_DEBUG "/GA" )
add_target_properties( ${tgt} COMPILE_FLAGS_RELEASE "/GB" )
add_target_properties( ${tgt} COMPILE_FLAGS_MYCONFIG1 "/GC" )
add_target_properties( ${tgt} COMPILE_FLAGS_MYCONFIG1 "/GD" )
like I do already:
add_target_properties( ${tgt} LINK_FLAGS_DEBUG "/Libpath:xxx1" )
add_target_properties( ${tgt} LINK_FLAGS_RELEASE "/Libpath:xxx2" )
add_target_properties( ${tgt} LINK_FLAGS_MYCONFIG1 "/Libpath:xxx3" )
add_target_properties( ${tgt} LINK_FLAGS_MYCONFIG1 "/Libpath:xxx4" )
The latter orks fine. Thus why it's not possible to obtain the same functionaltity for compile flags?
SirAnn
protective rights.
Am 26.06.2013 00:39, schrieb Leek, Jim:
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> [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<mailto: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> [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<mailto: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<http://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<http://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<http://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130626/2e963517/attachment.htm>
More information about the CMake
mailing list