Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] CMake find_path doesn't find files in r19c and r20-beta-3 #997

Closed
ViliusSutkus89 opened this issue Jun 4, 2019 · 3 comments
Closed
Labels

Comments

@ViliusSutkus89
Copy link

Hello,

#907 was closed as fixed in r19b, but I can reproduce it in r19c and r20-beta-3.

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

FILE(READ D:/projects/cm/src/test.txt TEST_FILE_CONTENTS)
message("contents of test.txt as read by FILE command: '${TEST_FILE_CONTENTS}'")

find_path(TEST test.txt PATHS D:/projects/cm/src)
message(FATAL_ERROR "TEST: ${TEST}")

Build with r19c

PS D:\Projects\cm> C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe -HD:\Projects\cm\src -BD:\Projects\cm\build -DANDROID_ABI=x86_64 -DANDROID_PLATFORM=android-18  -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\DevTools\Android\sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_VERSION=18 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_ANDROID_NDK=C:\DevTools\Android\sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\DevTools\Android\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -G Ninja -DCMAKE_MAKE_PROGRAM=C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\ninja.exe
-- Check for working C compiler: C:/DevTools/Android/SDK/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/DevTools/Android/SDK/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/DevTools/Android/SDK/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: C:/DevTools/Android/SDK/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
contents of test.txt as read by FILE command: 'Hello from test.txt.'
CMake Error at CMakeLists.txt:7 (message):
  TEST: TEST-NOTFOUND

Build with r20-beta-3

PS D:\Projects\cm> C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe -HD:\Projects\cm\src -BD:\Projects\cm\build -DANDROID_ABI=x86_64 -DANDROID_PLATFORM=android-18  -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\DevTools\Android\sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_VERSION=18 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_ANDROID_NDK=C:\DevTools\Android\sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\DevTools\Android\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -G Ninja -DCMAKE_MAKE_PROGRAM=C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\ninja.exe^C
PS D:\Projects\cm> ^C
PS D:\Projects\cm> ^C
PS D:\Projects\cm> C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe -HD:\Projects\cm\src -BD:\Projects\cm\build -DANDROID_ABI=x86_64 -DANDROID_PLATFORM=android-18  -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\DevTools\Android\sdk\android-ndk-r20-beta3 -DCMAKE_CXX_FLAGS= -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_VERSION=18 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_ANDROID_NDK=C:\DevTools\Android\sdk\android-ndk-r20-beta3 -DCMAKE_TOOLCHAIN_FILE=C:\DevTools\Android\sdk\android-ndk-r20-beta3\build\cmake\android.toolchain.cmake -G Ninja -DCMAKE_MAKE_PROGRAM=C:\DevTools\Android\sdk\cmake\3.10.2.4988404\bin\ninja.exe
-- Check for working C compiler: C:/DevTools/Android/SDK/android-ndk-r20-beta3/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/DevTools/Android/SDK/android-ndk-r20-beta3/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/DevTools/Android/SDK/android-ndk-r20-beta3/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: C:/DevTools/Android/SDK/android-ndk-r20-beta3/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
contents of test.txt as read by FILE command: 'Hello from test.txt.'
CMake Error at CMakeLists.txt:7 (message):
  TEST: TEST-NOTFOUND


-- Configuring incomplete, errors occurred!
See also "D:/Projects/cm/build/CMakeFiles/CMakeOutput.log".

Works with non crosscompile cmake-3.14.4

PS D:\Projects\cm> cmake --version
cmake version 3.14.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
PS D:\Projects\cm> cmake  -HD:\Projects\cm\src -BD:\Projects\cm\build
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.17763.
-- The C compiler identification is MSVC 19.21.27702.2
-- The CXX compiler identification is MSVC 19.21.27702.2
-- Check for working C compiler: C:/DevTools/Visual Studio/2019 Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/DevTools/Visual Studio/2019 Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/DevTools/Visual Studio/2019 Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/DevTools/Visual Studio/2019 Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
contents of test.txt as read by FILE command: 'Hello from test.txt.'
CMake Error at CMakeLists.txt:7 (message):
  TEST: D:/Projects/cm/src


-- Configuring incomplete, errors occurred!
See also "D:/Projects/cm/build/CMakeFiles/CMakeOutput.log".
@ViliusSutkus89
Copy link
Author

Never mind that.
Forgot that I had to

CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
CMAKE_FIND_ROOT_PATH_MODE_PATH=BOTH

when cross compiling

@subins2000
Copy link

Thank you @ViliusSutkus89 ! your solution helped me !

@hhb
Copy link
Collaborator

hhb commented Sep 9, 2020

Better to be ONLY because we don't want host system paths to be searched...

CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
CMAKE_FIND_ROOT_PATH_MODE_PATH=ONLY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants