4

So I have a library here /path/to/CMSIS/libarm_cortexM4lf_math.a I can't seem to find it using find_library with Cmake. Further more I can't find a simple text file with find_file or find_path.

I've tried the following (and many iterations thereof):

find_library(CMSIS_LIB libarm_cortexM4lf_math.a PATHS /path/to/CMSIS)

So then I thought I'd do something more simple and saved a file to /home/user/happy.txt and tried to

find_path(TEST_FILE happy.txt /home/user)

In all cases my variables are NOTFOUND.

I've read the cmake documentation for find_library, most of find_path, and skimmed find_file. They all seem to work the same way and I can't get any of them to work.

What am I missing here?

BLowe
  • 306
  • 1
  • 11
  • Do you **cross-compile** for arm? If yes, then the **toolchain** may limit search area with "sysroot" prefix. See [my answer](https://stackoverflow.com/questions/40054495/set-cmake-prefix-path-not-working-with-android-toolchain/40080575#40080575) about that limitations. – Tsyvarev Feb 12 '19 at 08:36
  • Yes I do. Looking at my toolchain file it doesn't look like CMAKE_SYSROOT is set anywhere and infact, if I print it out before I try to call the `find_*` command, it is empty. I tried to put a dummy file in CMAKE_FIND_ROOT_PATH and still can't find it. – BLowe Feb 12 '19 at 13:18
  • Does your toolchain set `CMAKE_FIND_ROOT_PATH` variable? Does it set any of `CMAKE_FIND_ROOT_PATH_MODE_*` variables? You can simply `grep` your toolchain for these strings. BTW, your `find_path` call lacks for `PATHS` keyword before `/home/user`. – Tsyvarev Feb 12 '19 at 13:37
  • Yes it sets CMAKE_FIND_ROOT_PATH. It sets: `CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY` – BLowe Feb 13 '19 at 15:04
  • 1
    So, exactly those `ONLY` values force `find_library` and `find_path` to search **only** under the directory, specified in `CMAKE_FIND_ROOT_PATH` variable. All other paths, event started with `/`, are treated relative to that directory. – Tsyvarev Feb 13 '19 at 15:17
  • I have the same problem but without any cross compiling etc. I have no toolchains, and I confirmed by printing them out that `CMAKE_FIND_ROOT_PATH_MODE_PROGRAM`, `CMAKE_FIND_ROOT_PATH_MODE_LIBRARY`, `CMAKE_FIND_ROOT_PATH_MODE_INCLUDE` are all blank, as is `CMAKE_FIND_ROOTH_PATH` and `CMAKE_SYSROOT`. I can't get find_path to work at all for finding files. I even tried this: `find_path(PATH_RESULT NAMES pagefile.sys PATHS "c:/")` as a test, and absolutely can't get PATH_RESULT to be anything but empty. Help! – Daniel Russell May 03 '20 at 01:51

0 Answers0