conan-center-index: [package] swig/4.0.2: find_package(SWIG) doesn't set SWIG_EXECUTABLE
Package and Environment Details (include every applicable attribute)
- Package Name/Version: swig/4.0.2
- Operating System+version: MacOS 11.6
- Compiler+version: Apple Clang 12
- Conan version: conan 1.47.0
- Python version: Python 3.9.12
Conan profile (output of conan profile show default
or conan profile show <profile>
if custom profile is in use)
[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
Steps to reproduce (Include if Applicable)
conanfile.py
from conans import CMake, ConanFile, tools
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake_find_package"
requires = "swig/4.0.2"
def build(self):
cmake = CMake(self)
cmake.verbose = True
cmake.configure()
cmake.build()
CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(Test)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
find_package(SWIG REQUIRED)
include(UseSWIG)
message("SWIG_DIR: ${SWIG_DIR}")
message("SWIG_EXECUTABLE: ${SWIG_EXECUTABLE}")
if ("${SWIG_EXECUTABLE}" STREQUAL "" OR "${SWIG_EXECUTABLE}" STREQUAL "SWIG_EXECUTABLE-NOTFOUND")
message(FATAL_ERROR "Didn't work.")
else()
message("It looks like it worked? Check variables above and see if they make sense.")
endif()
add_executable(test main.cpp)
main.cpp
int main() { return 0; }
If I build this the usual way, it’s unable to find the SWIG executable. However, if I build it as if it were a test package, it correctly populates SWIG_DIR
, SWIG_EXECUTABLE
, etc. I’ve tried this with and without the cmake
generator, tried it with cmake_find_package_multi
, CMakeDeps
, etc, and nothing works.
Logs (Include/Attach if Applicable)
conan test . swig/4.0.2@
SWIG_DIR: /Users/developer/.conan/data/swig/4.0.2/_/_/package/099d7b9cd06e9bd11e92b9a2ddf3b29cd986fdcb/bin/swig/swiglib
SWIG_EXECUTABLE: /Users/developer/.conan/data/swig/4.0.2/_/_/package/099d7b9cd06e9bd11e92b9a2ddf3b29cd986fdcb/bin/swig
mkdir build && cd build && conan install .. && cmake ..
SWIG_DIR:
SWIG_EXECUTABLE: SWIG_EXECUTABLE-NOTFOUND
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (11 by maintainers)
only works when the PATH is configured correctly. When you would run the following commands, it will build correctly:
If you don’t want conan to drive the compilation, you need modify your environment. This can be done with the
virtualrunenv
generator. Modify youconanfile.py
slightly:Then, you can do the following: