Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ dnaoad_setup_build_type("RelWithDebInfo")

include(subprojects/fypp.cmake)

# Checks version reported by fypp
execute_process(COMMAND ${FYPP} --version
OUTPUT_VARIABLE fypp_VERSION_RAW_OUTPUT)
string(STRIP ${fypp_VERSION_RAW_OUTPUT} fypp_VERSION_OUTPUT)
#message(STATUS "Fypp version detected : ${fypp_VERSION_OUTPUT}")

# Extra flags from cmake options and compiler capabilities
dnaoad_add_fypp_defines(FYPP_FLAGS)

Expand All @@ -80,8 +86,17 @@ set(FYPP_FLAGS "${FYPP_FLAGS}")
set(FYPP_CONFIG_FLAGS "${FYPP_FLAGS}")
# Make sure, the line-marker option is not set
list(REMOVE_ITEM FYPP_CONFIG_FLAGS "-n")
set(FYPP_BUILD_FLAGS "${FYPP_FLAGS}" "--file-var-root=${CMAKE_SOURCE_DIR}"
"$<IF:$<CONFIG:Debug>,-DDEBUG=1,-DDEBUG=0>")
if (${fypp_VERSION_OUTPUT} MATCHES "fypp 3.1")
set(FYPP_BUILD_FLAGS "${FYPP_FLAGS}"
"$<IF:$<CONFIG:Debug>,-DDEBUG=1,-DDEBUG=0>")
message(STATUS "Using fypp 3.1 for preprocessing")
elseif (${fypp_VERSION_OUTPUT} MATCHES "fypp 3.2")
set(FYPP_BUILD_FLAGS "${FYPP_FLAGS}" "--file-var-root=${CMAKE_SOURCE_DIR}"
"$<IF:$<CONFIG:Debug>,-DDEBUG=1,-DDEBUG=0>")
message(STATUS "Using fypp 3.2 for preprocessing")
else ()
message(ERROR " unsupported ${fypp_VERSION_OUTPUT} version")
endif ()

set(PYTHON_INTERPRETER "python3" CACHE STRING
"Python interpreter to use for preprocessor")
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ selected *_build* directory via
For windows compilation, either use a framework like *MinGW* and the
above compilation, or *cmake* is integrated with visual studio.

If locally installed, where to find Fortuno source files and the fypp
preprocessor can be specified at configutation time with

> cmake -DFETCHCONTENT_SOURCE_DIR_FYPP=/path/to/fypp

or

> cmake -DFETCHCONTENT_SOURCE_DIR_FORTUNO=/path/to/Fortuno

where in each cases, the path to the top level of the their
repositories (or also directly to the binary location for fypp) should
be specified.

Alternativelty, these packages will be fetched as subprojects from
their respectitve repositories.

### Preprocessing

The source code uses the [fypp](https://github.com/aradi/fypp)
Expand Down
16 changes: 12 additions & 4 deletions subprojects/fypp.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Variables influencing how subproject is obtained
set(CMAKE_REQUIRE_FIND_PACKAGE_Fypp ${DNAOAD_SUBPROJECT_REQUIRE_FIND})
set(CMAKE_DISABLE_FIND_PACKAGE_Fypp ${DNAOAD_SUBPROJECT_DISABLE_FIND})
# set FETCHCONTENT_SOURCE_DIR_Fypp to use a local copy of the subproject
# set FETCHCONTENT_SOURCE_DIR_FYPP to use a local copy of the subproject

# Make subproject available
FetchContent_Declare(
Expand All @@ -18,8 +18,16 @@ else ()
message(STATUS "Subproject Fypp: using local copy in ${fypp_BINARY_DIR}")
find_package(Python3 REQUIRED COMPONENTS Interpreter)
if(WIN32)
set(FYPP "${Python3_EXECUTABLE}" "${fypp_SOURCE_DIR}/bin/fypp")
else()
set(FYPP "${fypp_SOURCE_DIR}/bin/fypp")
if(EXISTS "${fypp_SOURCE_DIR}/fypp")
set(FYPP "${Python3_EXECUTABLE}" "${fypp_SOURCE_DIR}/fypp")
else ()
set(FYPP "${Python3_EXECUTABLE}" "${fypp_SOURCE_DIR}/bin/fypp")
endif()
else ()
if(EXISTS "${fypp_SOURCE_DIR}/fypp")
set(FYPP "${fypp_SOURCE_DIR}/fypp")
else ()
set(FYPP "${fypp_SOURCE_DIR}/bin/fypp")
endif()
endif()
endif ()