To Specify FindHoge.cmake Storage Location in CMake Without Hardcoding

Asked 2 years ago, Updated 2 years ago, 174 views

CMake is trying to create an environment-independent build file.
When I tried to use the LLVM and ffi Config.cmake fields in find_package(), I got the following error.If you use set() to specify the path, the error disappears, but CMakeLists.txt has a hardcoded environmentally sensitive path that fails to achieve its original purpose.
How do I specify a location for the Config.cmake file without hard code?

Failure to set (LLVM_DIR...)

CMake Error at src/CMakeLists.txt:5(find_package):
  Could not find a package configuration file provided by "LLVM" with any of
  The following names:

    LLVMConfig.cmake
    llvm-config.cmake

  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATHor set
  "LLVM_DIR" to a directory containing one of the above files.If "LLVM"
  providers a separate development package or SDK, be sure it has been
  installed.

CMakeLists.txt

cmake_minimum_required (VERSION 2.8)
project(sample)
# Explicitly specifying LLVM_DIR causes errors to disappear but become environmentally dependent
set (LLVM_DIR/usr/local/Cellar/llvm/3.5.1/share/llvm/cmake)
find_package (LLVM REQUIRED CONFIG)

CMakeLists.txt if you specify the llvm installed in the OS X Yosemite environment with HomeBrew.
MintLinux was stored in /usr/share/llvm-3.5/cmake/, so a rewrite was required.Considering the version change, I thought there was another way.

5/15 Around 19:00 Additional information

When running cmake, you could go out by specifying:

cmake-DLLVM_DIR=/path/to/LLVMConfig.cmake

build cmake

2022-09-30 20:11

1 Answers

It seems to have been self-resolved, but through PATH to clang

CC=clangcmake.

There seems to be a way to do this.


2022-09-30 20:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.