aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-07-01 20:32:52 +0000
committerwhitequark <whitequark@whitequark.org>2020-07-01 21:11:03 +0000
commit18bb70afca9cf4100e3230a12e9df1df99e43306 (patch)
treea7814db170b3d5d8dd1c731e0b29fcfac1fd701d /ecp5
parentf6e30f22f4334c36a42622e8fddd9cd92d0fe543 (diff)
downloadnextpnr-18bb70afca9cf4100e3230a12e9df1df99e43306.tar.gz
nextpnr-18bb70afca9cf4100e3230a12e9df1df99e43306.tar.bz2
nextpnr-18bb70afca9cf4100e3230a12e9df1df99e43306.zip
CMake: improve logic for discovering Trellis.
Diffstat (limited to 'ecp5')
-rw-r--r--ecp5/CMakeLists.txt26
1 files changed, 25 insertions, 1 deletions
diff --git a/ecp5/CMakeLists.txt b/ecp5/CMakeLists.txt
index 5bb82f4c..fe7de587 100644
--- a/ecp5/CMakeLists.txt
+++ b/ecp5/CMakeLists.txt
@@ -26,14 +26,38 @@ else()
message(STATUS "Trellis install prefix: ${TRELLIS_INSTALL_PREFIX}")
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)