Skip to content

Commit

Permalink
[#35] project: improve dependency handling and re-add git submodules
Browse files Browse the repository at this point in the history
Due to issues in build environments without a network connection,
it is necessary to allow users to pull phoenix's dependencies before
running any build scripts. By re-adding git submodules for the
dependencies, this can be made possible.

Because working with git submodules on larger projects with many
nested dependencies is a pain, however, phoenix still supports
downloading dependencies while configuring, so using the submodule
approach is not required.

(cherry picked from commit fbb042b)
  • Loading branch information
lmichaelis committed Nov 17, 2022
1 parent 272c2a3 commit 52e3136
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 92 deletions.
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[submodule "vendor/doctest"]
path = vendor/doctest
url = https://github.com/doctest/doctest.git
[submodule "vendor/mio"]
path = vendor/mio
url = https://github.com/mandreyel/mio.git
[submodule "vendor/lexy"]
path = vendor/lexy
url = https://github.com/foonathan/lexy.git
[submodule "vendor/fmt"]
path = vendor/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "vendor/libsquish"]
path = vendor/libsquish
url = https://github.com/lmichaelis/phoenix-libsquish.git
[submodule "vendor/glm"]
path = vendor/glm
url = https://github.com/g-truc/glm.git
122 changes: 30 additions & 92 deletions vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,101 +1,39 @@
include(FetchContent)

option(BUILD_STATIC_LIBS ON)
option(BUILD_SHARED_LIBS OFF)


# add doctest
FetchContent_Declare(
doctest
URL https://github.com/doctest/doctest/archive/refs/tags/v2.4.9.zip
URL_HASH SHA1=d1563419fa370c34c90e028c2e903a70c8dc07b2
)

if (NOT doctest_POPULATED)
message(STATUS "Downloading doctest")
FetchContent_Populate(doctest)
add_subdirectory(${doctest_SOURCE_DIR} ${doctest_BINARY_DIR})
endif ()


# add mio
FetchContent_Declare(
mio
URL https://github.com/mandreyel/mio/archive/3f86a95c0784d73ce6815237ec33ed25f233b643.zip
URL_HASH SHA1=62a0e43b07a6b66e415ad01f4b225c72a3c9935b
)

if (NOT mio_POPULATED)
message(STATUS "Downloading mio")
FetchContent_Populate(mio)
add_subdirectory(${mio_SOURCE_DIR} ${mio_BINARY_DIR})
endif ()


# add lexy
FetchContent_Declare(
lexy
URL https://github.com/foonathan/lexy/releases/download/v2022.05.1/lexy-src.zip
URL_HASH SHA1=252185ebbf004047725f9ed98b4e8b6e4aa06d98
)

if (NOT lexy_POPULATED)
message(STATUS "Downloading lexy")
FetchContent_Populate(lexy)
add_subdirectory(${lexy_SOURCE_DIR} ${lexy_BINARY_DIR})
endif ()


# add fmt
FetchContent_Declare(
fmt
URL https://github.com/fmtlib/fmt/releases/download/9.1.0/fmt-9.1.0.zip
URL_HASH SHA1=8de922ba88fccaec1e7778bc069f342084573486
)

if (NOT fmt_POPULATED)
message(STATUS "Downloading fmt")
FetchContent_Populate(fmt)
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR})
endif ()


# add glm
FetchContent_Declare(
glm
URL https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip
URL_HASH SHA1=45408897f419944fb28d8fd835791f237be2ec19
)

if (NOT glm_POPULATED)
message(STATUS "Downloading glm")
FetchContent_Populate(glm)
add_subdirectory(${glm_SOURCE_DIR} ${glm_BINARY_DIR})
endif ()
set(BUILD_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SQUISH_WITH_OPENMP OFF CACHE BOOL "" FORCE)

function(px_add_dependency NAME URL URL_HASH)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}/CMakeLists.txt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${NAME})
set(${NAME}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${NAME} PARENT_SCOPE)
else ()
FetchContent_Declare(
${NAME}
URL ${URL}
URL_HASH SHA1=${URL_HASH}
)

if (NOT ${NAME}_POPULATED)
message(STATUS "Downloading ${NAME}")
FetchContent_Populate(${NAME})
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
endif ()
endif ()
endfunction()

px_add_dependency(doctest https://github.com/doctest/doctest/archive/refs/tags/v2.4.9.zip d1563419fa370c34c90e028c2e903a70c8dc07b2)
px_add_dependency(mio https://github.com/mandreyel/mio/archive/3f86a95c0784d73ce6815237ec33ed25f233b643.zip 62a0e43b07a6b66e415ad01f4b225c72a3c9935b)
px_add_dependency(lexy https://github.com/foonathan/lexy/releases/download/v2022.05.1/lexy-src.zip 252185ebbf004047725f9ed98b4e8b6e4aa06d98)
px_add_dependency(fmt https://github.com/fmtlib/fmt/releases/download/9.1.0/fmt-9.1.0.zip 8de922ba88fccaec1e7778bc069f342084573486)
px_add_dependency(glm https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip 45408897f419944fb28d8fd835791f237be2ec19)
px_add_dependency(libsquish https://downloads.sourceforge.net/project/libsquish/libsquish-1.15.tgz 51844b9a8bc815a27e2cc0ffbede5fee3ef75110)

# msvc: disable -wno-* flags
if (NOT MSVC)
target_compile_options(mio INTERFACE -Wno-conversion)
target_compile_options(squish PRIVATE -Wno-unused-but-set-variable)
endif ()

# add libsquish
FetchContent_Declare(
libsquish
URL https://downloads.sourceforge.net/project/libsquish/libsquish-1.15.tgz
URL_HASH SHA1=51844b9a8bc815a27e2cc0ffbede5fee3ef75110
)

if (NOT libsquish_POPULATED)
message(STATUS "Downloading squish")
FetchContent_Populate(libsquish)

SET(BUILD_SQUISH_WITH_OPENMP OFF CACHE BOOL "" FORCE)
add_subdirectory(${libsquish_SOURCE_DIR} ${libsquish_BINARY_DIR})
target_include_directories(squish PUBLIC ${libsquish_SOURCE_DIR})

# msvc: disable -wno-* flags
if (NOT MSVC)
target_compile_options(squish PRIVATE -Wno-unused-but-set-variable)
endif ()
endif ()
target_include_directories(squish PUBLIC ${libsquish_SOURCE_DIR})
1 change: 1 addition & 0 deletions vendor/doctest
Submodule doctest added at b7c21e
1 change: 1 addition & 0 deletions vendor/fmt
Submodule fmt added at a33701
1 change: 1 addition & 0 deletions vendor/glm
Submodule glm added at bf71a8
1 change: 1 addition & 0 deletions vendor/lexy
Submodule lexy added at 5b7095
1 change: 1 addition & 0 deletions vendor/libsquish
Submodule libsquish added at ae7054
1 change: 1 addition & 0 deletions vendor/mio
Submodule mio added at 3f86a9

0 comments on commit 52e3136

Please sign in to comment.