Cmake output, cache, and debugging

I'm trying to debug a cmake file that works from the command line and fails in clion.   In particular, I have a function like this:

message("Already building dependency!")
message("Building dependency")
set(ALREADY_BUILDING ON CACHE BOOL "Build dependency")

add_subdirectory(${LOCATION} ${CMAKE_CURRENT_BINARY_DIR}/outdir)


My working hypothesis is that something in clion is setting ALREADY_BUILDING to ON, and so the add_subdirectory call never gets called.  I haven't been able to figure out where the cmake output is for a successful run (here "successful" is "cmake did not error out") so I can't check to see what's really going on.   (I need the cache variable because I don't have a lot of control over the targets that are added in the add_subdirectory call, otherwise I'd do an "if(target blah)").

Does anybody have any ideas?  My external cmake is 3.4.0 vs clion's 3.3.2, but I'm reasonably confident our build server is using an older cmake, and it works there too.

1 comment
Comment actions Permalink

Hi Jacob.

You're using set() with CACHE option, so the variable ends up at CMakeCache.txt and is already defined at the any subsequent CMake reload. May it be the reason of the problems? You can check if ALREADY_BUILDING is set via CMake/Cache tab. Does that help?
Also we have the issue about CMake output in the tracker:


Please sign in to leave a comment.