|
Boost Interest : |
Subject: Re: [Boost-cmake] CMAKE_CXX_FLAGS on Darwin...
From: Sean Chittenden (sean_at_[hidden])
Date: 2009-10-30 18:11:09
> Adding the ${CMAKE_CXX_FLAGS} to ADD_DEFINITIONS() seems redundant.to
> me because CMAKE_CXX_FLAGS already sets definitions passed to the c++
> compiler. I think this flag is more useful for setting
> config-dependent flags, e.g. CMAKE_CXX_FLAGS_DEBUG and
> CMAKE_CXX_FLAGS_RELEASE, but maybe others on the list can correct me
> if I'm wrong.
>
> As I understand it, you should just be able to use ADD_DEFINITIONS(
> -gdwarf2 ) and then later ADD_DEFINITIONS( -Wno-deprecated ) later in
> the code snippet. If you want to use CMAKE_CXX_FLAGS instead, just set
> it like so: SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf2 ).
For the code I'm working on, I have the following bootstrap steps:
1) sh autogen.sh # Calls cmake w/ platform specific flags and path
information
2) cmake # CMakeLists.txt detects whether or not I need to build boost
(eg: "if(EXISTS ${CONTRIBOBJ}/include/boost/asio.hpp)") and calls
execute_script() to compile boost with project-specific parameters.
CONTRIBOBJ is set to something like "obj/contrib-Darwin-i386".
3) I'm passing CMAKE_CXX_FLAGS to patch and contrib/boost/boosh.sh to
build boost
I can confirm that I'm setting CMAKE_CXX_FLAGS:
CMAKE_CXX_FLAGS: -gdwarf-2 -Wno-deprecated
via:
${CMAKE_COMMAND}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} \
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} \
-DCMAKE_IS_EXPERIMENTAL=YES_I_KNOW \ <<< Is this necessary
any more?
-DDCMAKE_VERBOSE_MAKEFILE=true \
[...]
And when I build boost: I'm not longer seeing either of those post
1.40.0. Starting with cmake2, it looks like CMAKE_CXX_FLAGS ceased
working but I don't know how or why. Is there a better way to pass
CXX_FLAGS to boost? -sc
cd /Users/sean/src/obj/contrib-Darwin-i386/boost-1.40.0.cmake4.obj/
libs/serialization/src && /opt/local/bin/g++-mp-4.3 -
DBOOST_ALL_NO_LIB=1 -I/Users/sean/src/obj/contrib-Darwin-i386/
boost-1.40.0.cmake4 -O3 -DNDEBUG -o CMakeFiles/
boost_serialization-mt-static.dir/basic_iserializer.cpp.o -c /Users/
sean/src/obj/contrib-Darwin-i386/boost-1.40.0.cmake4/libs/
serialization/src/basic_iserializer.cpp
?
PS Yes, I know I can get uname data in CMmake, but when I was first
porting some code to cmake's build system it was easier to wrap cmake
w/ a shell script and call uname than attempt to grok 100% of what
cmake has to offer. Slowly but surely I'm pushing various variables
out of autogen.sh in to cmake files.
> On Thu, Oct 29, 2009 at 3:37 PM, Sean Chittenden
> <sean_at_[hidden]> wrote:
>> I've been running with the following snippet in my boost build
>> directory for
>> a while.
>>
>>> IF(CMAKE_COMPILER_IS_GNUCXX)
>>> IF(APPLE)
>>> ADD_DEFINITIONS(${CMAKE_CXX_FLAGS} "-gdwarf-2")
>>> ENDIF(APPLE)
>>>
>>> # At some point in the future, this won't be requied to silence an
>>> # error message for boost, but for the time being it is.
>>> ADD_DEFINITIONS(${CMAKE_CXX_FLAGS} "-Wno-deprecated")
>>> ENDIF(CMAKE_COMPILER_IS_GNUCXX)
>>>
>>
>> If boost isn't built for the current project, I have cmake call a
>> shell
>> scipt to use cmake to build boost (passed in via
>> -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}). The -gdwarf-2 flag prevents
>> N_GSYM
>> errors on Darwin, similar to the following:
>>
>> cd
>> /Users/sean/src/obj/contrib-Darwin-i386/boost-1.40.0.cmake2.obj/
>> libs/thread/src
>> && /opt/local/bin/cmake -E cmake_link_script
>> CMakeFiles/boost_thread-mt-shared-debug.dir/link.txt --verbose=1
>> /opt/local/bin/g++-mp-4.3 -dynamiclib -headerpad_max_install_names
>> -o ../../../lib/libboost_thread-mt-d.dylib -install_name
>> /Users/sean/src/obj/contrib-Darwin-i386/boost-1.40.0.cmake2.obj/lib/
>> libboost_thread-mt-d.dylib
>> CMakeFiles/boost_thread-mt-shared-debug.dir/pthread/thread.cpp.o
>> CMakeFiles/boost_thread-mt-shared-debug.dir/pthread/exceptions.cpp.o
>> CMakeFiles/boost_thread-mt-shared-debug.dir/pthread/once.cpp.o ld:
>> warning:
>> can't find atom for N_GSYM stabs uninitialized_flag:G(0,1440) in
>> CMakeFiles/boost_thread-mt-shared-debug.dir/pthread/thread.cpp.old:
>> warning:
>> can't find atom for N_GSYM stabs being_initialized:G(0,1440) in
>> CMakeFiles/boost_thread-mt-shared-debug.dir/pthread/thread.cpp.o
>> /opt/local/bin/cmake -E cmake_progress_report
>> /Users/sean/src/obj/contrib-Darwin-i386/boost-1.40.0.cmake2.obj/
>> CMakeFiles
>> 6
>>
>> Starting with cmake2, it looks like CMAKE_CXX_FLAGS is being reset
>> somewhere
>> along the lines. Is there a correct/better way to pass this in to
>> CMake or
>> is there a way to have Boost cmake automatically set -gdwarf-2
>> using the
>> above logic? tia. -sc
-- Sean Chittenden sean_at_[hidden]