Use cmake to package executable with dependencies

Problems building or running the engine, queries about how to use features etc.
Post Reply
reaper
Gnoblar
Posts: 1
Joined: Sun Mar 26, 2023 10:30 am

Use cmake to package executable with dependencies

Post by reaper »

I have a simple Ogre+CEGUI application, and I'd like to use cmake to package the final executable, together with any dependencies (*.so, *.a), into an install folder. I'm new to cmake and stuck at the package dependencies part.

Ogre Version: 13.5.3
Operating System: Debian 11 (bullseye)
CMake: 3.18.4

The goal is to get a distributable package by running make && make install.

This is CMakeLists.txt:

Code: Select all

cmake_minimum_required (VERSION 3.10)
project(Test_With_Cegui)

# required for Ogre 1.11+
set(CMAKE_CXX_STANDARD 11)

# Include necessary submodules
set(CMAKE_MODULE_PATH
  "${PROJECT_SOURCE_DIR}/CMake"
)

find_package(OGRE REQUIRED COMPONENTS Bites CONFIG)
find_package(CEGUI REQUIRED)

# add the source files as usual
add_executable(Test_With_Cegui BasicTutorial1.cpp)

# add CEGUI to include path
include_directories(${CEGUI_INCLUDE_DIR})

# this also sets the includes and pulls third party dependencies
target_link_libraries(Test_With_Cegui OgreBites ${CEGUI_LIBRARIES} ${CEGUI_OgreRenderer_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION bin)

Result is a folder containing just the executable file - bin/Test_With_Cegui
Adding additional install directives gave errors:

Code: Select all

install(FILES ${CEGUI_LIBRARIES} TYPE LIB)
install(FILES ${CEGUI_OgreRenderer_LIBRARIES} TYPE LIB)
  file INSTALL cannot find "/home/user/ogre3d_apps/src/optimized":
  No such file or directory.

Am I missing something? There must be a way to get cmake to package the library dependencies?

Post Reply