Skip to content

Commit

Permalink
Added option to link against system assimp/glbinding libraries instea…
Browse files Browse the repository at this point in the history
…d of building as dependencies.
  • Loading branch information
spillner committed May 9, 2023
1 parent 7a564f0 commit 7233996
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
10 changes: 10 additions & 0 deletions doomsday/apps/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ endif()
target_link_libraries (client PUBLIC doomsdaygui)
deng_link_libraries (client PUBLIC DengGui DengDoomsday DengGameKit DengGloom)

if (DE_USE_SYSTEM_GLBINDING)
target_link_libraries (client PUBLIC glbinding)
deng_link_libraries (client PUBLIC glbinding)
endif()

if (DE_USE_SYSTEM_ASSIMP)
target_link_libraries (client PUBLIC assimp)
deng_link_libraries (client PUBLIC assimp)
endif()

# Extensions ----------------------------------------------------------------------------

target_link_libraries (client PRIVATE importsave)
Expand Down
34 changes: 27 additions & 7 deletions doomsday/build/scripts/build_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def print_config(cfg):
IS_MSYS = os.getenv('MSYSTEM') == 'MSYS'
IS_MINGW = os.getenv('MSYSTEM') == 'MINGW64'

build_foundation = build_assimp = build_glbinding = True

PATCH_DIR = os.path.abspath(os.path.dirname(__file__))

if IS_MSYS:
Expand Down Expand Up @@ -69,7 +71,7 @@ def print_config(cfg):
)
]

if IS_MACOS: del dependencies[2] # using glbinding from Homebrew
if IS_MACOS: build_glbinding = False # using glbinding from Homebrew

import shutil
import subprocess
Expand Down Expand Up @@ -111,6 +113,12 @@ def print_config(cfg):
elif opt == '-d':
idx += 1
cfg['build_dir'] = os.path.abspath(sys.argv[idx])
elif opt == '--skip-foundation':
build_foundation = False
elif opt == '--skip-assimp':
build_assimp = False
elif opt == '--skip-glbinding':
build_glbinding = False
else:
raise Exception('Unknown option: ' + opt)
idx += 1
Expand All @@ -120,14 +128,17 @@ def print_config(cfg):
Usage: build_deps.py [opts] [commands] build-dir
Commands:
build Build using existing config.
clean Clean the build directory.
build Build using existing config.
clean Clean the build directory.
Options:
-G <generator> Use CMake <generator> when configuring build.
-t <type> Set CMake build type (e.g., Release).
-d <dir> Set build directory.
--help Show this help.
-G <generator> Use CMake <generator> when configuring build.
-t <type> Set CMake build type (e.g., Release).
-d <dir> Set build directory.
--help Show this help.
--skip-foundation Do not build the_Foundation library
--skip-assimp Do not build Open Asset Importer library
--skip-glbinding Do not build glbinding library
""")
print_config(cfg)
exit(0)
Expand All @@ -147,6 +158,15 @@ def print_config(cfg):
shutil.rmtree(PRODUCTS_DIR)
os.makedirs(PRODUCTS_DIR, exist_ok=True)

if not build_glbinding:
del dependencies[2]

if not build_assimp:
del dependencies[1]

if not build_foundation:
del dependencies[0]

for long_name, git_url, git_tag, cmake_opts in dependencies:
name = os.path.splitext(os.path.basename(git_url))[0]
src_dir = os.path.join(BUILD_DIR, name)
Expand Down
8 changes: 6 additions & 2 deletions doomsday/cmake/FindAssimp.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
include (assimp-config) # from deps
if (DE_USE_SYSTEM_ASSIMP)
include (${DE_CMAKE_DIR}/assimp-system.cmake)
else ()
include (assimp-config) # from deps
endif ()

add_library (assimp INTERFACE)
set (_cxxFlags ${ASSIMP_CXX_FLAGS})
separate_arguments (_cxxFlags)
target_compile_options (assimp INTERFACE ${_cxxFlags})
target_include_directories (assimp INTERFACE ${ASSIMP_INCLUDE_DIRS})
target_link_libraries (assimp INTERFACE -L${ASSIMP_LIBRARY_DIRS} -l${ASSIMP_LIBRARIES})
target_link_libraries (assimp INTERFACE ${ASSIMP_LIBRARIES})
10 changes: 8 additions & 2 deletions doomsday/cmake/Findglbinding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ message (STATUS "Looking for glbinding...")
if (APPLE)
# Homebrew's glbinding CMake config doesn't seem to work.
include (${glbinding_DIR}/cmake/glbinding/glbinding-export.cmake)
elseif (DE_USE_SYSTEM_GLBINDING)
include (${DE_CMAKE_DIR}/glbinding-system.cmake)
else ()
# Use the glbinding built by build_deps.py.
include (${DE_DEPENDS_DIR}/products/glbinding-config.cmake)
set (glbinding_DIR ${DE_DEPENDS_DIR}/products)
endif ()

if (MSYS OR WIN32)
set (DE_GLBINDING_VERSION 3)
if (DE_USE_SYSTEM_GLBINDING)
set (DE_GLBINDING_VERSION ${glbinding_VERSION_MAJOR})
elseif (MSYS OR WIN32)
set (DE_GLBINDING_VERSION 3)
else ()
set (DE_GLBINDING_VERSION 2)
endif ()

message (STATUS "Found glbinding version ${DE_GLBINDING_VERSION}")
2 changes: 2 additions & 0 deletions doomsday/cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ option (DE_ENABLE_SDK "Enable installation of the Doomsday SDK" OFF)
option (DE_ENABLE_TESTS "Enable tests" OFF)
option (DE_ENABLE_TOOLS "Enable tools" ON)
option (DE_ENABLE_DEPLOYMENT "Enable deployment of all dependencies" ON)
option (DE_USE_SYSTEM_ASSIMP "Use system-provided assimp library" OFF)
option (DE_USE_SYSTEM_GLBINDING "Use system-provided glbinding library" OFF)
option (DE_FIXED_ASM
"Use inline assembler for fixed-point math"
${DE_FIXED_ASM_DEFAULT}
Expand Down
16 changes: 13 additions & 3 deletions doomsday/libs/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ deng_link_libraries (libgui PUBLIC DengCore)
target_link_libraries (libgui PRIVATE SDL2 stb assimp)
if (NOT DE_HAVE_OPENGL_ES)
target_compile_definitions (libgui PRIVATE DE_GLBINDING_VERSION=${DE_GLBINDING_VERSION})
target_link_libraries (libgui PUBLIC glbinding::glbinding)
if (DE_USE_SYSTEM_GLBINDING)
target_link_libraries (libgui PUBLIC glbinding)
else ()
target_link_libraries (libgui PUBLIC glbinding::glbinding)
endif ()
endif ()
if (WIN32)
target_link_libraries (libgui PUBLIC opengl32.lib)
Expand Down Expand Up @@ -140,11 +144,17 @@ elseif (CYGWIN)
COMPONENT client
)
endif ()
if (UNIX_LINUX)
if (UNIX_LINUX AND NOT DE_USE_SYSTEM_ASSIMP)
install (
FILES ${ASSIMP_ROOT_DIR}/lib/libassimp.so.4
${ASSIMP_ROOT_DIR}/lib/libassimp.so.4.1.0
${glbinding_DIR}/lib/libglbinding.so.2
DESTINATION ${DE_INSTALL_LIB_DIR}
COMPONENT client
)
endif ()
if (UNIX_LINUX AND NOT DE_USE_SYSTEM_GLBINDING)
install (
FILES ${glbinding_DIR}/lib/libglbinding.so.2
${glbinding_DIR}/lib/libglbinding.so.2.1.4
DESTINATION ${DE_INSTALL_LIB_DIR}
COMPONENT client
Expand Down

0 comments on commit 7233996

Please sign in to comment.