ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.64k stars 399 forks source link

Build fails if this library is used in a non-git folder #60

Closed VedantParanjape closed 3 years ago

VedantParanjape commented 3 years ago

So, If this library is used in a folder which is not a git repository build will fail

CMakeLists.txt

# Specify minimum cmake version required
cmake_minimum_required(VERSION 3.4)

# Download ftxui library
include(FetchContent)

set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
  GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
)

FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
  FetchContent_Populate(ftxui)
  add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# Find Threads Library
find_package( Threads )

# CMake project description and project specific settings
project(simppru-console
        VERSION 1.0
        DESCRIPTION "Console for simpPRU"
        HOMEPAGE_URL "https://github.com/VedantParanjape/simpPRU/")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

# Set pru-gcc as the compiler

# Specify Build type
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

######## SOURCES ########
# Add source files and header files
file(GLOB PROJECT_HEADERS *.hpp)
file(GLOB PROJECT_SOURCES *.cpp)
set(PROJECT_FILES
    ${PROJECT_HEADERS}
    ${PROJECT_SOURCES})

######## TARGETS ########
# Add executables
add_executable(${PROJECT_NAME}-${CMAKE_PROJECT_VERSION} ${PROJECT_FILES})
set_target_properties(${PROJECT_NAME}-${CMAKE_PROJECT_VERSION} PROPERTIES CXX_STANDARD 17)
target_include_directories(${PROJECT_NAME}-${CMAKE_PROJECT_VERSION} PUBLIC 
  $<BUILD_INTERFACE:${simppru_SOURCE_DIR}/include/console>
  $<BUILD_INTERFACE:${ftxui_SOURCE_DIR}/include>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

# Link ftxui and Thread library
target_link_libraries(${PROJECT_NAME}-${CMAKE_PROJECT_VERSION}
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
${CMAKE_THREAD_LIBS_INIT}
)

Output message:

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at build/_deps/ftxui-src/CMakeLists.txt:10 (project):
  VERSION "0.3." format invalid.

-- Configuring incomplete, errors occurred!

Issue is with the following line: https://github.com/ArthurSonzogni/FTXUI/blob/406355df8c18d2a33a772fd55cd1c7641ab33dc8/CMakeLists.txt#L12

VedantParanjape commented 3 years ago

Submitted patch in #61