# Syntax: # # yosys_cxx_library( {SHARED|STATIC} # OUTPUT_NAME # [INCLUDE_IN_ALL | INCLUDE_IN_ALL_IF ] # ) # # Creates a libary target `` with `SHARED` or `STATIC` scope called `` (or `` if # not specified), placed in the root of the build directory and prefixed with `${YOSYS_PROGRAM_PREFIX}`. # Target is built by default and installed only if `` (an `if()` expression) is true. # function(yosys_cxx_library arg_TARGET arg_SCOPE) cmake_parse_arguments(PARSE_ARGV 2 arg "INCLUDE_IN_ALL" "OUTPUT_NAME;INCLUDE_IN_ALL_IF" "") if (NOT arg_OUTPUT_NAME) message(FATAL_ERROR "OUTPUT_NAME argument is mandatory") endif() set(include_in_all FALSE) if (arg_INCLUDE_IN_ALL) set(include_in_all TRUE) elseif (${arg_INCLUDE_IN_ALL_IF}) set(include_in_all TRUE) endif() add_library(${arg_TARGET} ${arg_SCOPE}) set_target_properties(${arg_TARGET} PROPERTIES PREFIX "${YOSYS_PROGRAM_PREFIX}" OUTPUT_NAME "${arg_OUTPUT_NAME}" RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) if (include_in_all) install(TARGETS ${arg_TARGET} DESTINATION ${YOSYS_INSTALL_LIBDIR}) else() set_target_properties(${arg_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE) endif() endfunction() # Syntax: # # yosys_cxx_executable( # [OUTPUT_NAME ] # [INCLUDE_IN_ALL | INCLUDE_IN_ALL_IF ] # ) # # Creates an executable target `` scope called `` (or `` if not specified), placed # in the root of the build directory and prefixed with `${YOSYS_PROGRAM_PREFIX}`. Target is built by # default and installed only if `INCLUDE_IN_ALL` is provided or `` (an `if()` expression) is true. # function(yosys_cxx_executable arg_TARGET) cmake_parse_arguments(PARSE_ARGV 1 arg "INCLUDE_IN_ALL" "OUTPUT_NAME;INCLUDE_IN_ALL_IF" "") if (NOT arg_OUTPUT_NAME) message(FATAL_ERROR "OUTPUT_NAME argument is mandatory") endif() set(include_in_all FALSE) if (arg_INCLUDE_IN_ALL) set(include_in_all TRUE) elseif (${arg_INCLUDE_IN_ALL_IF}) set(include_in_all TRUE) endif() add_executable(${arg_TARGET}) set_target_properties(${arg_TARGET} PROPERTIES PREFIX "${YOSYS_PROGRAM_PREFIX}" OUTPUT_NAME "${arg_OUTPUT_NAME}" RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) if (include_in_all) install(TARGETS ${arg_TARGET} DESTINATION ${YOSYS_INSTALL_BINDIR}) else() set_target_properties(${arg_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE) endif() endfunction() # Syntax: # # yosys_python_executable( ) # # Installs Python script `` as an executable in the standard binary directory, adding a launcher wrapper # if the platform requires it. Inside ``, several substitutions are available: # - `@PYTHON_SHEBANG@` will be replaced with an appropriate shebang line (without the initial `#!`) # - `@YOSYS_PROGRAM_PREFIX@` will be replaced with the program prefix # - any other `@\w+@` tokens have unspecified behavior and must not be used # function(yosys_python_executable basename source) if (CMAKE_SYSTEM_NAME STREQUAL MSYS) execute_process( COMMAND cygpath -w -m ${CMAKE_INSTALL_BINDIR}/python3 OUTPUT_VARIABLE PYTHON_SHEBANG COMMAND_ERROR_IS_FATAL ANY ) add_executable(${basename} ${CMAKE_SOURCE_DIR}/misc/launcher.c) target_compile_definitions(${basename} GUI=0) install(TARGETS ${basename} DESTINATION ${YOSYS_INSTALL_BINDIR}) set(scriptname ${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}${basename}-script.py) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${source} ${scriptname} @ONLY) install(FILES ${scriptname} DESTINATION ${YOSYS_INSTALL_BINDIR}) else() set(PYTHON_SHEBANG "/usr/bin/env python3") set(scriptname ${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}${basename}${CMAKE_EXECUTABLE_SUFFIX}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${source} ${scriptname} USE_SOURCE_PERMISSIONS @ONLY) install(PROGRAMS ${scriptname} DESTINATION ${YOSYS_INSTALL_BINDIR}) endif() endfunction()