Hi Roman,
I'm not necessarily only talking about CMAKE_CXX_FLAGS here. I define compile
flags for my targets in a number of different ways. Like:
find_package( ROOT COMPONENTS ${ROOT_LINK_COMPONENTS} REQUIRED )
include( ${ROOT_USE_FILE} )
...
add_definitions( ${ATLAS_DEFINITIONS} )
...
add_definitions( -Wno-unused-local-typedefs )
if( APPLE )
add_definitions( -Wno-tautological-undefined-compare )
add_definitions( -Wno-inconsistent-missing-override )
endif()
...
include_directories( BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_INCLUDE_OUTPUT_DIRECTORY} )
if( ARG_INCLUDE_DIRS )
target_include_directories( ${libName} PUBLIC ${ARG_INCLUDE_DIRS} )
endif()
The trickiest are the definitions that I pull in from external packages. For
instance the second line in this example produces a *lot* of duplicate entries
in the compilation flags. In this particular case the flags *are* defined like
the following in the file that I include with ${ROOT_USE_FILE}:
add_definitions(${ROOT_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")
Now, CMake definitely doesn't remove the duplicates that enter in all these
ways. So now I was wondering what I could do to improve on the situation...
Cheers,
Attila
> On 06 Oct 2015, at 12:58, Roman Bolshakov <[email protected]> wrote:
>
> CMake performs deduplication of per-target flags for sure.
>
> However I'm not sure if CMAKE_CXX_FLAGS is deduplicated. But I consider this
> variable as global flags for the whole project which is defined at topmost
> CMakeLists.txt. If you need to specify some flags specifically for a target
> use target_compile_options.
>
> —
> Sent from Mailbox
>
>
> On Mon, Oct 5, 2015 at 4:23 PM, Attila Krasznahorkay
> <[email protected]> wrote:
>
> Dear All,
>
> Let me try a simpler question this time. (I'm a bit disappointed that nobody
> had any comments on my question about sub-projects.)
>
> I'm trying to clean up my project's build a bit. As it collects compilation
> flags from a few separate places, by the time it finishes collecting
> everything, the compilation commands are usually very long. As they have many
> duplications. Like:
>
> -m64 -pipe -W
> -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments
> -pthread -std=c++11 -Wno-deprecated-declaration
> s -stdlib=libc++ -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char
> -fno-common -Qunused-arguments -pthread -std=c++
> 11 -Wno-deprecated-declarations -stdlib=libc++ -Wno-unused-local-typedefs
> -Wno-tautological-undefined-compare -Wno-incon
> sistent-missing-override -m64 -pipe -W -Wall -Woverloaded-virtual
> -fsigned-char -fno-common -Qunused-arguments -pthread
> -std=c++11 -Wno-deprecated-declarations -stdlib=libc++ -m64 -pipe -W -Wall
> -Woverloaded-virtual -fsigned-char -fno-commo
> n -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-declarations
> -stdlib=libc++ -m64 -pipe -W -Wall -Woverloaded-vi
> rtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11
> -Wno-deprecated-declarations -stdlib=libc++ -m64
> -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common
> -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-dec
> larations -stdlib=libc++ -m64 -pipe -fsigned-char -fno-common
> -Qunused-arguments -pthread -std=c++11 -stdlib=libc++
>
> Naturally it would help the build log reading tremendously if I could remove
> the duplications from these lines. But I can't find a good way of doing it.
> How could I weed out all the duplications in the CXXFLAGS associated to a
> given target?
>
> Cheers,
> Attila
> --
>
> 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
>
>
--
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