[arch-general] Removing compiler flag from CMake output
Hi, As I already feared, someone tried to build mysql-connector-c++ [1] against libmysqlclient 5.6.20-1, which results in the following error: …/driver/mysql_metadata.cpp:1216:74: error: ‘dynamic_cast’ not permitted with -fno-rtti How do I remove that compiler flag from CMake output? I already tried adding -frtti to CXXFLAGS in makepkg.conf, but this didn't change the compiler flags. I also tried to add it as an environment variable to the cmake call in PKGBUILD and add a set(CMAKE_CXX_FLAGS "-frtti") at several places in …/CMakeLists.txt, but to no avail, CMake keeps saying -- MySQL CXXFLAGS: -I/usr/include/mysql -fPIC -pipe -msse4.1 -mmmx -fomit-frame-pointer -fstack-protector-strong --param=ssp-buffer-size=4 -fno-strict-aliasing -DBIG_JOINS=1 -felide-constructors -fno-rtti -g -DNDEBUG And why isn't this a problem when building against libmariadbclient 10.0.14? Regards, Marcel [1] https://aur.archlinux.org/packages/mysql-connector-c%2B%2B/
How do I remove that compiler flag from CMake output?
I already tried adding -frtti to CXXFLAGS in makepkg.conf, but this didn't change the compiler flags. I also tried to add it as an environment variable to the cmake call in PKGBUILD and add a
set(CMAKE_CXX_FLAGS "-frtti")
That isn't a good idea that overwrites CMAKE_CXX_FLAGS entirely rather than appending. Regardless of that there are several ways of specifying flags. It can be done at the target level (e.g. target_compile_definitions(mylib COMPILE_OPTIONS ...) ) or globally using CMAKE_CXX_FLAGS_*. There are several flags for different release types, e.g. CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_RELEASE CMAKE_CXX_FLAGS I believe there are other ways to set flags as well. You should look at how the developers have set their flags in their CMakeLists.txt files and do it the same way. As a hack you could check what's set the CMake cache and manually change it $ make edit_cache HTH
* Delcypher <delcypher@gmail.com> (Thu, 9 Oct 2014 15:26:57 +0100):
Regardless of that there are several ways of specifying flags. It can be done at the target level (e.g. target_compile_definitions(mylib COMPILE_OPTIONS ...) ) or globally using CMAKE_CXX_FLAGS_*. There are several flags for different release types, e.g.
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_RELEASE CMAKE_CXX_FLAGS
I believe there are other ways to set flags as well.
I already set CMAKE_CXX_RELEASE and CMAKE_CXX_FLAGS, but to no avail.
You should look at how the developers have set their flags in their CMakeLists.txt files and do it the same way.
Searching for "-fnortti" in CMakeLists.txt and grepping for that value in the complete source code didn't reveal anything. The only flags that are explicitly set are "Environment compile flags", set using SET(MYSQLCPPCONN_COMPILE_FLAGS_ENV "$ENV{CPPFLAGS} ${MYSQL_CXXFLAGS} $ENV{CXXFLAGS}") but somehow CMake outputs "MySQL CXXFLAGS" with "-fnortti" included. Ah! They're in the PKGBUILD of mysql. Removing -fnortti there solved this issue and mysql-connector-c++ builds again. Regards, Marcel
participants (2)
-
Delcypher
-
Marcel Korpel