Сейчас столкнулся с такой проблемой. Прописал в CMakeLists.txt опцию:
set(CMAKE_CXX_FLAGS "-O0")
Удаляю файл CMakeCache.txt и каталог CMakeFiles. Запускаю собрку с вербзом, и вижу, что сборка идет без опций -O0:
$ cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xi/work/loloswitcher
$ make VERBOSE=1
/usr/bin/cmake -H/home/xi/work/loloswitcher -B/home/xi/work/loloswitcher --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/xi/work/loloswitcher/CMakeFiles /home/xi/work/loloswitcher/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/xi/work/loloswitcher'
make -f CMakeFiles/loloswitcher.dir/build.make CMakeFiles/loloswitcher.dir/depend
make[2]: Entering directory `/home/xi/work/loloswitcher'
cd /home/xi/work/loloswitcher && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher/CMakeFiles/loloswitcher.dir/DependInfo.cmake --color=
Dependee "/home/xi/work/loloswitcher/CMakeFiles/loloswitcher.dir/DependInfo.cmake" is newer than depender "/home/xi/work/loloswitcher/CMakeFiles/loloswitcher.dir/depend.internal".
Dependee "/home/xi/work/loloswitcher/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/xi/work/loloswitcher/CMakeFiles/loloswitcher.dir/depend.internal".
Scanning dependencies of target loloswitcher
make[2]: Leaving directory `/home/xi/work/loloswitcher'
make -f CMakeFiles/loloswitcher.dir/build.make CMakeFiles/loloswitcher.dir/build
make[2]: Entering directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 1
[ 20%] Building CXX object CMakeFiles/loloswitcher.dir/Main.cpp.o
/usr/bin/c++ -o CMakeFiles/loloswitcher.dir/Main.cpp.o -c /home/xi/work/loloswitcher/Main.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 2
[ 40%] Building CXX object CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o
/usr/bin/c++ -o CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o -c /home/xi/work/loloswitcher/KeyLayout.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 3
[ 60%] Building CXX object CMakeFiles/loloswitcher.dir/Config.cpp.o
/usr/bin/c++ -o CMakeFiles/loloswitcher.dir/Config.cpp.o -c /home/xi/work/loloswitcher/Config.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 4
[ 80%] Building CXX object CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o
/usr/bin/c++ -o CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o -c /home/xi/work/loloswitcher/ParseHelper.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 5
[100%] Building CXX object CMakeFiles/loloswitcher.dir/EventQueue.cpp.o
/usr/bin/c++ -o CMakeFiles/loloswitcher.dir/EventQueue.cpp.o -c /home/xi/work/loloswitcher/EventQueue.cpp
Linking CXX executable loloswitcher
/usr/bin/cmake -E cmake_link_script CMakeFiles/loloswitcher.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/loloswitcher.dir/Main.cpp.o CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o CMakeFiles/loloswitcher.dir/Config.cpp.o CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o CMakeFiles/loloswitcher.dir/EventQueue.cpp.o -o loloswitcher -rdynamic -lX11 -lpcre -lpthread
make[2]: Leaving directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 1 2 3 4 5
[100%] Built target loloswitcher
make[1]: Leaving directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_start /home/xi/work/loloswitcher/CMakeFiles 0
Запускаю то же самое второй раз:
$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xi/work/loloswitcher
$ make VERBOSE=1
/usr/bin/cmake -H/home/xi/work/loloswitcher -B/home/xi/work/loloswitcher --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/xi/work/loloswitcher/CMakeFiles /home/xi/work/loloswitcher/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/xi/work/loloswitcher'
make -f CMakeFiles/loloswitcher.dir/build.make CMakeFiles/loloswitcher.dir/depend
make[2]: Entering directory `/home/xi/work/loloswitcher'
cd /home/xi/work/loloswitcher && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher /home/xi/work/loloswitcher/CMakeFiles/loloswitcher.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/xi/work/loloswitcher'
make -f CMakeFiles/loloswitcher.dir/build.make CMakeFiles/loloswitcher.dir/build
make[2]: Entering directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 1
[ 20%] Building CXX object CMakeFiles/loloswitcher.dir/Main.cpp.o
/usr/bin/c++ -O0 -g -o CMakeFiles/loloswitcher.dir/Main.cpp.o -c /home/xi/work/loloswitcher/Main.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 2
[ 40%] Building CXX object CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o
/usr/bin/c++ -O0 -g -o CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o -c /home/xi/work/loloswitcher/KeyLayout.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 3
[ 60%] Building CXX object CMakeFiles/loloswitcher.dir/Config.cpp.o
/usr/bin/c++ -O0 -g -o CMakeFiles/loloswitcher.dir/Config.cpp.o -c /home/xi/work/loloswitcher/Config.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 4
[ 80%] Building CXX object CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o
/usr/bin/c++ -O0 -g -o CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o -c /home/xi/work/loloswitcher/ParseHelper.cpp
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 5
[100%] Building CXX object CMakeFiles/loloswitcher.dir/EventQueue.cpp.o
/usr/bin/c++ -O0 -g -o CMakeFiles/loloswitcher.dir/EventQueue.cpp.o -c /home/xi/work/loloswitcher/EventQueue.cpp
Linking CXX executable loloswitcher
/usr/bin/cmake -E cmake_link_script CMakeFiles/loloswitcher.dir/link.txt --verbose=1
/usr/bin/c++ -O0 -g CMakeFiles/loloswitcher.dir/Main.cpp.o CMakeFiles/loloswitcher.dir/KeyLayout.cpp.o CMakeFiles/loloswitcher.dir/Config.cpp.o CMakeFiles/loloswitcher.dir/ParseHelper.cpp.o CMakeFiles/loloswitcher.dir/EventQueue.cpp.o -o loloswitcher -rdynamic -lX11 -lpcre -lpthread
make[2]: Leaving directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_report /home/xi/work/loloswitcher/CMakeFiles 1 2 3 4 5
[100%] Built target loloswitcher
make[1]: Leaving directory `/home/xi/work/loloswitcher'
/usr/bin/cmake -E cmake_progress_start /home/xi/work/loloswitcher/CMakeFiles 0
На этот раз опция -O0 применяется.
Почему так? Как исправить?