diff options
author | whitequark <whitequark@whitequark.org> | 2020-07-01 22:02:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 22:02:36 +0000 |
commit | 4a2964c91568c63928f1d916aef1a1b84a9e608d (patch) | |
tree | a7814db170b3d5d8dd1c731e0b29fcfac1fd701d | |
parent | c0901fb972e34d2d16b3ac0074a18542ba1c448d (diff) | |
parent | 18bb70afca9cf4100e3230a12e9df1df99e43306 (diff) | |
download | nextpnr-4a2964c91568c63928f1d916aef1a1b84a9e608d.tar.gz nextpnr-4a2964c91568c63928f1d916aef1a1b84a9e608d.tar.bz2 nextpnr-4a2964c91568c63928f1d916aef1a1b84a9e608d.zip |
Merge pull request #465 from whitequark/fix-trellis-discovery
Improve Trellis discovery logic
-rw-r--r-- | ecp5/CMakeLists.txt | 30 | ||||
-rw-r--r-- | ice40/CMakeLists.txt | 2 |
2 files changed, 28 insertions, 4 deletions
diff --git a/ecp5/CMakeLists.txt b/ecp5/CMakeLists.txt index 303208ed..fe7de587 100644 --- a/ecp5/CMakeLists.txt +++ b/ecp5/CMakeLists.txt @@ -25,15 +25,39 @@ else() "Trellis install prefix") message(STATUS "Trellis install prefix: ${TRELLIS_INSTALL_PREFIX}") - if(NOT DEFINED TRELLIS_LIBDIR) + if(NOT TRELLIS_LIBDIR) + # The pytrellis library isn't a normal shared library, but rather a native Python library; + # it does not follow the normal platform conventions for shared libraries, so we can't just + # use find_library() here. Instead, we emulate the useful parts of the find_library() logic + # for use with find_path(). + set(pytrellis_paths) + foreach(prefix_path ${CMAKE_PREFIX_PATH}) + list(APPEND pytrellis_paths ${prefix_path}/lib) + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND pytrellis_paths ${prefix_path}/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + endif() + endforeach() + list(APPEND pytrellis_paths ${CMAKE_LIBRARY_PATH}) + if(NOT NO_CMAKE_SYSTEM_PATH) + foreach(prefix_path ${CMAKE_SYSTEM_PREFIX_PATH}) + list(APPEND pytrellis_paths ${prefix_path}/lib) + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND pytrellis_paths ${prefix_path}/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + endif() + endforeach() + list(APPEND pytrellis_paths ${CMAKE_SYSTEM_LIBRARY_PATH}) + endif() + message(STATUS "Searching for pytrellis in: ${pytrellis_paths}") + if(WIN32) set(pytrellis_lib pytrellis.pyd) else() set(pytrellis_lib pytrellis${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() + find_path(TRELLIS_LIBDIR ${pytrellis_lib} HINTS ${TRELLIS_INSTALL_PREFIX}/lib/${TRELLIS_PROGRAM_PREFIX}trellis - PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH} + PATHS ${pytrellis_paths} PATH_SUFFIXES ${TRELLIS_PROGRAM_PREFIX}trellis DOC "Location of the pytrellis library") if(NOT TRELLIS_LIBDIR) @@ -42,7 +66,7 @@ else() endif() message(STATUS "Trellis library directory: ${TRELLIS_LIBDIR}") - if(NOT DEFINED TRELLIS_DATADIR) + if(NOT TRELLIS_DATADIR) set(TRELLIS_DATADIR ${TRELLIS_INSTALL_PREFIX}/share/${TRELLIS_PROGRAM_PREFIX}trellis) endif() message(STATUS "Trellis data directory: ${TRELLIS_DATADIR}") diff --git a/ice40/CMakeLists.txt b/ice40/CMakeLists.txt index 1bf64905..89203bbc 100644 --- a/ice40/CMakeLists.txt +++ b/ice40/CMakeLists.txt @@ -27,7 +27,7 @@ else() "IceStorm install prefix") message(STATUS "IceStorm install prefix: ${ICESTORM_INSTALL_PREFIX}") - if(NOT DEFINED ICEBOX_DATADIR) + if(NOT ICEBOX_DATADIR) set(ICEBOX_DATADIR ${ICESTORM_INSTALL_PREFIX}/share/icebox) endif() message(STATUS "icebox data directory: ${ICEBOX_DATADIR}") |