Files
yosys/cmake/YosysConfigScript.cmake
T
tangxifan 02dc5a82d7 [core] add a cmake option to disable unit test during compilation; Use cmake_current_source for submodule integration
[core] debug yosys version extraction

[core] debug

[core] now cache the cmake source dir

[core] debug

[core] debug kernel dependencies

[core] debug common include directories

[core] debug

[core] debug simlib_help.inc

[core] debug pmgen py path in cmake

[core] syntax

[core] debug flex source

[core] restore

[core] debug executable output as it now shows linking to .

[core] debug yosys-abc directory

[core] debug cmake share directory

[core] debug yosys abc

[core] restore shared directory location as yosys requires fixed location

[core] rework link target to yosys sub dir under build

[core] fixed the bug on yosys-config.install location for install

[core] cmake syntax

[core] correct the location for share directory

[core] debug

[core] debug

[core] debug

[core] enforce internal attributes; rename the YOSYS_ENABLE_UNIT_TESTS; use YOSYS_CMAKE_BINARY_DIR for all

[core] apply review comments

[core] rename

[core] change all the CMAKE_BINARY_DIR to YOSYS_CMAKE_BINARY_DIR

[core] replace CMAKE_SOURCE_DIR to YOSYS_CMAKE_SOURCE_DIR
2026-08-21 12:09:04 -07:00

71 lines
1.8 KiB
CMake

# Syntax:
#
# yosys_config_script({BUILD|INSTALL})
#
# Generates a `yosys-config` executable with embedded paths for in-tree builds or after installation.
#
function(yosys_config_script scope)
if (scope STREQUAL BUILD)
set(BINDIR ${YOSYS_CMAKE_BINARY_DIR})
set(LIBDIR ${YOSYS_CMAKE_BINARY_DIR})
set(DATDIR ${YOSYS_CMAKE_BINARY_DIR}/share)
set(suffix "")
elseif (scope STREQUAL INSTALL)
set(BINDIR ${YOSYS_INSTALL_FULL_BINDIR})
set(LIBDIR ${YOSYS_INSTALL_FULL_LIBDIR})
set(DATDIR ${YOSYS_INSTALL_FULL_DATADIR})
set(suffix ".install")
else()
message(FATAL_ERROR "Invalid scope ${scope}")
endif()
set(link_flags)
if (scope STREQUAL BUILD OR YOSYS_INSTALL_LIBRARY)
set(link_flags -L${LIBDIR})
endif()
set(platform_link_flags)
set(platform_libs)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(platform_link_flags -undefined dynamic_lookup)
endif()
if (MINGW)
set(platform_libs -l:yosys.exe.a)
endif()
if (MINGW AND YOSYS_INSTALL_DRIVER)
set(platform_link_flags -L${LIBDIR})
endif()
set(CXX ${CMAKE_CXX_COMPILER})
string(JOIN " " CXXFLAGS
-std=c++${CMAKE_CXX_STANDARD}
${CMAKE_CXX_FLAGS}
${CMAKE_CXX_COMPILE_OPTIONS_PIC}
-D_YOSYS_
"-DYOSYS_VER=\"${YOSYS_VERSION}\""
"-DYOSYS_MAJOR=${YOSYS_VERSION_MAJOR}"
"-DYOSYS_MINOR=${YOSYS_VERSION_MINOR}"
"-DYOSYS_COMMIT=${YOSYS_VERSION_COMMIT}"
-I${DATDIR}/include
)
string(JOIN " " LINKFLAGS
${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
${link_flags}
${platform_link_flags}
)
string(JOIN " " LIBS
${platform_libs}
)
configure_file(${YOSYS_CMAKE_SOURCE_DIR}/misc/yosys-config.in
${YOSYS_PROGRAM_PREFIX}yosys-config${suffix}
USE_SOURCE_PERMISSIONS
@ONLY
)
if (scope STREQUAL INSTALL)
install(PROGRAMS ${YOSYS_CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}yosys-config.install
RENAME yosys-config
DESTINATION ${YOSYS_INSTALL_BINDIR}
)
endif()
endfunction()