cmake_min_version icon indicating copy to clipboard operation
cmake_min_version copied to clipboard

Error with binary search

Open nlohmann opened this issue 1 year ago • 7 comments

I tried project yalov/cmake_min_test1 while downloading more versions of CMake.

First run:

./cmake_min_version.py ~/Downloads/cmake_min_test1/
Found 118 CMake binaries from directory tools

[  0%] CMake 3.11.3   ✔ works
[ 12%] CMake 3.4.1    ✘ error
[ 25%] CMake 3.8.2    ✔ works
[ 38%] CMake 3.6.1    ✘ error
[ 50%] CMake 3.7.1    ✘ error
[ 62%] CMake 3.8.0    ✔ works
[ 86%] CMake 3.7.2    ✘ error
[100%] Minimal working version: CMake 3.8.0

cmake_minimum_required(VERSION 3.8.0)

Second run:

./cmake_min_version.py ~/Downloads/cmake_min_test1/
Found 125 CMake binaries from directory tools

[  0%] CMake 3.12.2   ✔ works
[ 12%] CMake 3.4.3    ✘ error
[ 25%] CMake 3.9.2    ✘ error
[ 38%] CMake 3.10.3   ✔ works
[ 50%] CMake 3.9.6    ✔ works
[ 62%] CMake 3.9.4    ✔ works
[ 86%] CMake 3.9.3    ✘ error
[100%] Minimal working version: CMake 3.9.4

cmake_minimum_required(VERSION 3.9.4)

I need to check why CMake 3.9.3 failed here.

nlohmann avatar Apr 02 '24 16:04 nlohmann

After deleting CMake 3.9.3, it works again:

./cmake_min_version.py ~/Downloads/cmake_min_test1/
Found 129 CMake binaries from directory tools

[  0%] CMake 3.13.0   ✔ works
[ 12%] CMake 3.5.0    ✘ error
[ 25%] CMake 3.9.4    ✔ works
[ 38%] CMake 3.7.1    ✘ error
[ 50%] CMake 3.8.2    ✔ works
[ 62%] CMake 3.8.0    ✔ works
[ 86%] CMake 3.7.2    ✘ error
[100%] Minimal working version: CMake 3.8.0

cmake_minimum_required(VERSION 3.8.0)

nlohmann avatar Apr 02 '24 16:04 nlohmann

Interesting:

[ 83%] CMake 3.8.2    ✔ works
[ 83%] CMake 3.9.0    ✘ error
[ 83%] CMake 3.9.1    ✔ works
[ 84%] CMake 3.9.2    ✘ error
[ 84%] CMake 3.9.3    ✘ error

nlohmann avatar Apr 02 '24 17:04 nlohmann

More output:

[ 83%] CMake 3.8.2    ✔ works
[ 83%] CMake 3.9.0    ✘ error
    Boost  found.
    Found Boost components:
       system;thread
    CMake Error in /Users/niels/Code/repositories/cmake_min_version/tools/cmake-3.9.0-Darwin-x86_64/CMake.app/Contents/share/cmake-3.9/Modules/FindBoost.cmake:
      cmake_policy PUSH without matching POP
    Call Stack (most recent call first):
      CMakeLists.txt:27 (find_package)


[ 83%] CMake 3.9.1    ✔ works
[ 84%] CMake 3.9.2    ✘ error
    Boost  found.
    Found Boost components:
       system;thread
    CMake Error in /Users/niels/Code/repositories/cmake_min_version/tools/cmake-3.9.2-Darwin-x86_64/CMake.app/Contents/share/cmake-3.9/Modules/FindBoost.cmake:
      cmake_policy POP without matching PUSH
    Call Stack (most recent call first):
      CMakeLists.txt:27 (find_package)


[ 84%] CMake 3.9.3    ✘ error
    Boost  found.
    Found Boost components:
       system;thread
    CMake Error in /Users/niels/Code/repositories/cmake_min_version/tools/cmake-3.9.3-Darwin-x86_64/CMake.app/Contents/share/cmake-3.9/Modules/FindBoost.cmake:
      cmake_policy POP without matching PUSH
    Call Stack (most recent call first):
      CMakeLists.txt:27 (find_package)


[ 84%] CMake 3.9.4    ✔ works

There seem to be a bug in CMake 3.9.0, 3.9.2, and 3.9.3 when it comes to Boost.

nlohmann avatar Apr 02 '24 18:04 nlohmann

I leave this open as concept bug - the binary search assumes monotonous behavior; that is, if a project can be built by version x, then it should also be buildable with any higher version. This issue shows that this is not the case.

nlohmann avatar Apr 02 '24 18:04 nlohmann

With #26, I changed the behavior of the full search to return the latest version such that this and all later version can successfully build the project.

nlohmann avatar Apr 02 '24 20:04 nlohmann

Does the last cmake_min_test1 also have the same problems on 3.9.0, 3.9.2, and 3.9.3? I replace lib names to autopath target_link_libraries(${PROJECT_NAME} PRIVATE ${Boost_LIBRARY_DIRS})

yalov avatar Apr 03 '24 11:04 yalov

There are different problems now:

[  0%] CMake 3.16.1   ✔ works
[ 11%] CMake 3.8.2    ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 22%] CMake 3.13.0   ✔ works
[ 33%] CMake 3.10.3   ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 44%] CMake 3.11.4   ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 56%] CMake 3.12.2   ✔ works
[ 75%] CMake 3.12.0   ✔ works
[100%] Minimal working version: CMake 3.12.0

cmake_minimum_required(VERSION 3.12.0)

nlohmann avatar Apr 04 '24 11:04 nlohmann