find_* works not correctly when cross compile windows mingw project on linux OS
Hi. I am working Linux Debian jessie OS I want to find directory (${HOME}/testdir), which contains nested file (mydir/myfile.txt):
builder@dev-workstation:~/test$ mkdir -p ${HOME}/testdir/mydir
builder@dev-workstation:~/test$ touch ${HOME}/testdir/mydir/myfile.txt
builder@dev-workstation:~/test$ ls ${HOME}/testdir/mydir
myfile.txt
builder@dev-workstation:~/test$
I am using following cmake:
builder@dev-workstation:~/test$ cmake --version
cmake version 3.8.0
CMakeLists.txt looks like:
#############################################################
cmake_minimum_required(VERSION 3.8)
project(testapp)
find_path(TESTDIR NAMES mydir/myfile.txt HINTS $ENV{HOME}/testdir)
message("TESTDIR: ${TESTDIR}")
add_executable(testapp testapp.cpp)
#############################################################
it is output - found properly:
builder@dev-workstation:~/test$ cmake -G "Unix Makefiles"
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
TESTDIR: /home/builder/testdir
-- Configuring done
-- Generating done
-- Build files have been written to: /home/builder/test
but when i use following toolchain file (cross compilation - mingw64):
#############################################################
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 10)
SET(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#############################################################
then output looks like:
builder@dev-workstation:~/test$ cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.file.cmake
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- 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: /usr/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
TESTDIR: TESTDIR-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /home/builder/test
not found my directory. So i am unable to find any package, path etc when i cross compile any project