patrickfrey / strus

Library implementing the storage and the query evaluation for a text search engine. It uses on a key value store database interface to store its data. Currently there exists an implementation based on the google LevelDB library.
http://www.project-strus.net
Mozilla Public License 2.0
47 stars 1 forks source link

Cannot set custom CFLAGS or CXXFLAGS #65

Open andreasbaumann opened 8 years ago

andreasbaumann commented 8 years ago

For instance:

cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DLIB_INSTALL_DIR=lib -DCMAKE_CXX_FLAGS_RELEASE='-g -O0' -DCMAKE_C_FLAGS_RELEASE='-g -O0' .

or

cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DLIB_INSTALL_DIR=lib -DCMAKE_CXX_FLAGS='-g -O0' -DCMAKE_C_FLAGS='-g -O0' .

has now effect as I can see in:

Compiler:
  C++ compilation flags: -std=c++98  -Wall -pedantic -g -Wfatal-errors -fvisibility=hidden -fPIC -O3
  C compilation flags: -std=c99 -Wall -pedantic -Wfatal-errors -fPIC -O3

This is because in cmake/build_rules.cmake the corresponding flag variables are just brutally set:

if(CMAKE_COMPILER_IS_GNUCXX)
set( STRUS_OPTIMIZATION_LEVEL "3" )
set( CMAKE_CXX_FLAGS "-std=c++98  -Wall -pedantic -g -Wfatal-errors -fvisibility=hidden -fPIC -O${STRUS_O
PTIMIZATION_LEVEL}" )
set( CMAKE_C_FLAGS "-std=c99 -Wall -pedantic -Wfatal-errors -fPIC -O${STRUS_OPTIMIZATION_LEVEL}" )
endif()

With 'make VERBOSE=1' I can even see, that flags get used in parallel:

[ 33%] Building CXX object src/utils/CMakeFiles/strus_private_utils.dir/utils.cpp.o
cd /home/user/strusAnalyzer_tsv/src/utils && /bin/c++    -I/home/user/strusAnalyzer_tsv/include  -std=c++98  -Wall -pedantic -g -Wfatal-errors -fvisibility=hidden -fPIC -O3 -g -O0   -o CMakeFiles/strus_private_utils.dir/utils.cpp.o -c /home/user/strusAnalyzer_tsv/src/utils/utils.cpp

O3 and O0 in parallel.

All cmake support should be fixed in this regard, see also tipps in:

http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/

Several reasons why this fix is important:

This bug is valid for all strus repos.

andreasbaumann commented 8 years ago

Some third-party modules have to set their own compilation flags (snowball, textcat, etc.). Also there we should combine the flags set by the user and the default ones known to work on the code.