-1

In the following section of the main CMakeLists.txt file,

# Allow builds to complete with warnings (do not set -Werror)
option(CIVETWEB_ALLOW_WARNINGS "Do not stop build if there are warnings" OFF)
message(STATUS "Build if there are warnings - ${CIVETWEB_ALLOW_WARNINGS}")

when I switch CIVETWEB_ALLOW_WARNINGS to ON, I still get the message

-- Build if there are warnings - OFF

even if I use "reload the cmake project" in clion.

Using cmake from the command line, the output is correctly

-- Build if there are warnings - ON

What do I have to do in clion such that cmake changes are refreshed correctly?


UPDATE 1:

I changed in clion's cmake cache CIVETWEB_ALLOW_WARNINGS to ON, but I still get

error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]
#define _GNU_SOURCE /* for setgroups() */

UPDATE 2:

The following lines from CMakeLists.txt are also relevant for -Werror:

if (NOT CIVETWEB_ALLOW_WARNINGS)
  add_c_compiler_flag(-Werror)
endif()

and

if (NOT CIVETWEB_ALLOW_WARNINGS)
    add_cxx_compiler_flag(-Werror)
endif()

However, note that ${CIVETWEB_ALLOW_WARNINGS} in the message above is already evaluated to OFF in clion and to ON on the command line.

DaveFar
  • 7,078
  • 4
  • 50
  • 90

2 Answers2

3

Seems you have two problems.

Firstly, there's the issue of "Changing an option in cmake doesn't lead to the option really changing". That's caused by CMakeCache being annoying.

Now you solved that by changing the CMakeCache by hand (instead of clearing it and doing "reload CMake project"), you have a second problem: your flag doesn't work. I assume that flag is supposed to stop -Werror being passed to the compiler, but we can see from your error message that this is still happening. Without seeing more of the CMakeLists.txt I can't be more help on that one. Perhaps you're having trouble with removing flags from CMake?

Community
  • 1
  • 1
Chris Kitching
  • 2,559
  • 23
  • 37
  • Thanks for the answer, Chris (+1). Yes, you are right, I have two problems. I did solve the cache problem, but not the second problem. I added UPDATE 2 to my question in relation to the second problem. – DaveFar Mar 09 '16 at 19:45
0
  1. Now CLion has a "Reset Cache and Reload Project" option. (as of CLion 2020.1 or 2019.3, not sure as of older versions)

It is located in: CMake Tab -> Gear icon on the left pane under the green "Reload CMake Project" -> red recycle-button "Reset Cache and Reload Project": CLion Reset Cache and Reload Project

Caution, this will delete your built binaries, forcing you to rebuild a project.

  1. On older versions you can delete cmake-build-debug/cmake-build-release directories and trigger "Reload CMake Project". This have almost the same effect as 1).

  2. If you don't want to rebuild your project afterwards, you can delete file CMakeCache.txt from cmake-build-debug/cmake-build-release directory and trigger "Reload CMake Project" from CMake tab.

Edit (25 Jul 2021)

  1. You can go to your CMake output (by default it is called something like this: cmake-build-*) folder, open the CMakeCache.txt file, look for the option you are interested in and swith it from OPTION=ON to OPTION=OFF and then press "Reload CMake Project".
a_girl
  • 959
  • 7
  • 22