Issue
I am learning CMake; my learning material is based around CLion and its native integration with CMake. But I also like to reinforce my learning by doing the same things by invoking cmake
with appropriate arguments from the command-line, so that my learning is not tightly coupled to an IDE. While learning about installing CMake projects, I observed a discrepancy in the destination directory when installation is done from the CLion IDE versus when done from the command line. I would like to understand why this discrepancy exists, because my understanding is that IDE integrations with CMake are ultimately just wrappers around CLI invocations of CMake, so ultimately, a user should be able to see consistent behavior between the IDE and outside of it.
Screenshots, and text of those screenshots are below the question details, to keep this post better organized.
I downloaded CLion, with a 30-day trial from here.
I did not install any plugins or any form of add-ons.
I am trying to build googletest-release-1.11.0 from source, with CMake, in the CLion IDE.
I downloaded googletest-release-1.11.0 from here to C:\libs\googletest-release-1.11.0
.
In the Settings > Build, Execution, Deployment > CMake
settings of the CLion IDE, I configure:
- Build type: Release
- Generator: Ninja
- CMake options:
-DCMAKE_INSTALL_PREFIX="install-dir" -Dgtest_force_shared_crt=ON
When I reload the CMake project, the following cmake.exe
invocation is revealed in the CMake window:
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.3.3/bin/ninja/win/x64/ninja.exe" -DCMAKE_INSTALL_PREFIX=install-dir -Dgtest_force_shared_crt=ON -G Ninja -S C:\libs\googletest-release-1.11.0 -B C:\libs\googletest-release-1.11.0\cmake-build-release
When I click Build > Build All in 'Release'
the project, the following cmake.exe
invocation is revealed in the Messages window: "C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target all -j 18
And when I click Build > Install
, the following cmake.exe
invocation is revealed in the Messages window: "C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target install -j 18
Note (from the screenshot below) that the install directory is C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/
, which is a subdirectory of the binary directory.
But when I repeat these same three commands from a Windows Command Prompt, the install directory is C:/libs/googletest-release-1.11.0/install-dir/
, which is a subdirectory of the source directory.
My question is: why is the install directory different when run from the CLion IDE versus when run outside the IDE, even though I'm building the same project, from the same source directory with the same cmake.exe
invocations?
I would really like to understand why the same commands results in different behavior when invoked by CLion vs. when run outside of CLion.
I note that in the configurations performed above, CMAKE_INSTALL_PREFIX
is specified as a relative path, but as far as I can make out, the CMake documentation doesn't say explicitly what the behavior should be with respect to relative paths and/or any relationship to the source directory versus the binary directory.
Screenshots
If it helps, below is the text of the above screenshots, in the same order:
CMake configuration/generation stage from the CLion IDE:
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.3.3/bin/ninja/win/x64/ninja.exe" -DCMAKE_INSTALL_PREFIX=install-dir -Dgtest_force_shared_crt=ON -G Ninja -S C:\libs\googletest-release-1.11.0 -B C:\libs\googletest-release-1.11.0\cmake-build-release
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at googlemock/CMakeLists.txt:45 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at googletest/CMakeLists.txt:56 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Could NOT find Python (missing: Python_EXECUTABLE Interpreter)
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Configuring done (9.5s)
-- Generating done (0.0s)
-- Build files have been written to: C:/libs/googletest-release-1.11.0/cmake-build-release
[Finished]
Build from CLion IDE:
====================[ Build | all | Release ]===================================
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target all -j 18
[1/11] Building CXX object googletest\CMakeFiles\gtest_main.dir\src\gtest_main.cc.obj
[2/11] Building CXX object googlemock\CMakeFiles\gmock_main.dir\src\gmock_main.cc.obj
[3/11] Building CXX object googlemock\CMakeFiles\gmock.dir\src\gmock-all.cc.obj
[4/11] Building CXX object googlemock\CMakeFiles\gmock_main.dir\src\gmock-all.cc.obj
[5/11] Building CXX object googlemock\CMakeFiles\gmock.dir\__\googletest\src\gtest-all.cc.obj
[6/11] Building CXX object googletest\CMakeFiles\gtest.dir\src\gtest-all.cc.obj
[7/11] Linking CXX static library lib\gmock.lib
[8/11] Linking CXX static library lib\gtest.lib
[9/11] Linking CXX static library lib\gtest_main.lib
[10/11] Building CXX object googlemock\CMakeFiles\gmock_main.dir\__\googletest\src\gtest-all.cc.obj
[11/11] Linking CXX static library lib\gmock_main.lib
Build finished
Install from CLion IDE:
====================[ Install | Release ]=======================================
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target install -j 18
[0/1] Install the project...
-- Install configuration: "Release"
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-cardinalities.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-function-mocker.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-more-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-more-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-nice-strict.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock-spec-builders.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/gmock.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/custom
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/custom/gmock-generated-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/custom/gmock-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/custom/gmock-port.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/custom/README.md
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/gmock-internal-utils.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/gmock-port.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gmock/internal/gmock-pp.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/gmock.lib
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/gmock_main.lib
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/pkgconfig/gmock.pc
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/pkgconfig/gmock_main.pc
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/cmake/GTest/GTestTargets.cmake
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/cmake/GTest/GTestTargets-release.cmake
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/cmake/GTest/GTestConfigVersion.cmake
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/cmake/GTest/GTestConfig.cmake
-- Up-to-date: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-death-test.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-message.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-param-test.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-printers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-spi.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-test-part.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest-typed-test.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest_pred_impl.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/gtest_prod.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/custom
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/custom/gtest-port.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/custom/gtest-printers.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/custom/gtest.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/custom/README.md
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-death-test-internal.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-filepath.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-internal.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-param-util.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-port-arch.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-port.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-string.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/include/gtest/internal/gtest-type-util.h
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/gtest.lib
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/gtest_main.lib
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/pkgconfig/gtest.pc
-- Installing: C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/lib/pkgconfig/gtest_main.pc
Install finished
CMake configuration/generation, build, and install from Command Prompt:
c:\libs\googletest-release-1.11.0>"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.3.3/bin/ninja/win/x64/ninja.exe" -DCMAKE_INSTALL_PREFIX=install-dir -Dgtest_force_shared_crt=ON -G Ninja -S C:\libs\googletest-release-1.11.0 -B C:\libs\googletest-release-1.11.0\cmake-build-release
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at googlemock/CMakeLists.txt:45 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at googletest/CMakeLists.txt:56 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Could NOT find Python (missing: Python_EXECUTABLE Interpreter)
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Configuring done (8.6s)
-- Generating done (0.0s)
-- Build files have been written to: C:/libs/googletest-release-1.11.0/cmake-build-release
c:\libs\googletest-release-1.11.0>"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target all -j 18
[11/11] Linking CXX static library lib\gmock_main.lib
c:\libs\googletest-release-1.11.0>"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target install -j 18
[0/1] Install the project...
-- Install configuration: "Release"
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-cardinalities.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-function-mocker.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-more-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-more-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-nice-strict.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock-spec-builders.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/gmock.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/custom
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/custom/gmock-generated-actions.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/custom/gmock-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/custom/gmock-port.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/custom/README.md
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/gmock-internal-utils.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/gmock-port.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gmock/internal/gmock-pp.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/gmock.lib
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/gmock_main.lib
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/pkgconfig/gmock.pc
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/pkgconfig/gmock_main.pc
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/cmake/GTest/GTestTargets.cmake
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/cmake/GTest/GTestTargets-release.cmake
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/cmake/GTest/GTestConfigVersion.cmake
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/cmake/GTest/GTestConfig.cmake
-- Up-to-date: C:/libs/googletest-release-1.11.0/install-dir/include
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-death-test.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-matchers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-message.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-param-test.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-printers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-spi.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-test-part.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest-typed-test.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest_pred_impl.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/gtest_prod.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/custom
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/custom/gtest-port.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/custom/gtest-printers.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/custom/gtest.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/custom/README.md
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-death-test-internal.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-filepath.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-internal.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-param-util.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-port-arch.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-port.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-string.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/include/gtest/internal/gtest-type-util.h
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/gtest.lib
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/gtest_main.lib
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/pkgconfig/gtest.pc
-- Installing: C:/libs/googletest-release-1.11.0/install-dir/lib/pkgconfig/gtest_main.pc
Update: Trying to explore @Tsyvarev's answer, I tried the following:
cd c:\libs\googletest-release-1.11.0\
- Run CMake configure/generate (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.3.3/bin/ninja/win/x64/ninja.exe" -DCMAKE_INSTALL_PREFIX=install-dir -Dgtest_force_shared_crt=ON -G Ninja -S C:\libs\googletest-release-1.11.0 -B C:\libs\googletest-release-1.11.0\cmake-build-release
- Build (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target all -j 18
- Install (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target install -j 18
Result: installation still happens to C:/libs/googletest-release-1.11.0/install-dir/
instead of the expected C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/
.
Update: I can achieve the consistency of behavior between CLion and non-CLion by doing the following:
mkdir c:\libs\googletest-release-1.11.0\cmake-build-result
cd c:\libs\googletest-release-1.11.0\cmake-build-result
- Run CMake configure/generate (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.3.3/bin/ninja/win/x64/ninja.exe" -DCMAKE_INSTALL_PREFIX=install-dir -Dgtest_force_shared_crt=ON -G Ninja -S C:\libs\googletest-release-1.11.0 -B C:\libs\googletest-release-1.11.0\cmake-build-release
- Build (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target all -j 18
- Install (using the same command revealed from the CLion IDE):
"C:\Program Files\JetBrains\CLion 2023.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\libs\googletest-release-1.11.0\cmake-build-release --target install -j 18
Result: installation now happens to C:/libs/googletest-release-1.11.0/cmake-build-release/install-dir/
.
I guess this means CLion is behind-the-scenes doings steps 1 and 2, and maintaining that created directory as the CWD.
Solution
There is no magic here: You specify a relative path for CMAKE_INSTALL_PREFIX
parameter, so CMake interprets it relative to the current working directory and automatically transforms it to the absolute path. Internal mechanism is described in that my answer: CMake: Convert relative path to absolute path or the cmake command line arguments.
When cmake
is run from CLion IDE, the current working director is the build one: note that CLion specifies source directory with -S
parameter but doesn't specify -B
parameter, assuming build directory to be the current one. That is, the relative path in CMAKE_INSTALL_PREFIX
is interpreted against the build directory.
But when you run cmake
from Command Prompt, the current working directory is C:/libs/googletest-release-1.11.0
. So the relative path in CMAKE_INSTALL_PREFIX
is interpreted against this directory.
Answered By - Tsyvarev Answer Checked By - Marilyn (WPSolving Volunteer)