user809409
user809409

Reputation: 511

CMake Fails until you remove CMake Cache

I have a project that I am managing using CMake and I have run into some very strange behavior that I don't understand. If I clear out my build directory, run cmake, run make, then run my program my program crashes every time because I fail an assertion somewhere in pthreads/boost threads. No matter how many times I make, and make clean this project it crashes every time I run it. However, if I then remove CMaketCache.txt, regenerate my makefiles, build and run, the program runs as expected every time.

In summary I need to follow the following steps for my code to work...

  1. Run Cmake
  2. Run Make
  3. rm CMakeCache.txt
  4. Run Make
  5. Run program

It appears that the Make files before and after I remove CMakeCache.txt differ. What could explain this behavior?

Upvotes: 1

Views: 7563

Answers (1)

Bill Hoffman
Bill Hoffman

Reputation: 1752

Do you have git installed? If so, you can use this trick:

  • Run cmake
  • make
  • git add .
  • git commit -m ""
  • rm CMakeCache.txt
  • run make
  • git diff

Some odd things I can see in what you are saying. I don't see why your program would recompile anything just because you removed the CMakeCache.txt. Everything should be up-to-date from the first make, so something is bad there... My guess is that it is finding a different thread library or no thread library the second time.

Upvotes: 1

Related Questions