Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hunterize] Add support for installs, with a project config #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
69 changes: 66 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
cmake_minimum_required(VERSION 2.8)
project(bento4)
cmake_minimum_required(VERSION 3.0.2)
project(bento4 LANGUAGES CXX VERSION "0.0.0")

# Variables
set(SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Source/C++)
Expand All @@ -26,6 +26,12 @@ file(GLOB AP4_SOURCES
${SOURCE_METADATA}/*.cpp
${SOURCE_SYSTEM}/StdC/*.cpp
)
file(GLOB AP4_HEADERS
${SOURCE_CORE}/*.h
${SOURCE_CODECS}/*.h
${SOURCE_CRYPTO}/*.h
${SOURCE_METADATA}/*.h
)

if(WIN32)
set(AP4_SOURCES ${AP4_SOURCES} ${SOURCE_SYSTEM}/Win32/Ap4Win32Random.cpp)
Expand All @@ -36,17 +42,74 @@ endif()
add_library(ap4 STATIC ${AP4_SOURCES})

# Includes
include_directories(
list(APPEND BENTO4_INCLUDE_DIRS
${SOURCE_CORE}
${SOURCE_CODECS}
${SOURCE_CRYPTO}
${SOURCE_METADATA}
)
target_include_directories(
ap4
PUBLIC
"$<BUILD_INTERFACE:${BENTO4_INCLUDE_DIRS}>"
)

# Apps
file(GLOB BENTO4_APPS RELATIVE ${SOURCE_ROOT}/Apps ${SOURCE_ROOT}/Apps/*)
foreach(app ${BENTO4_APPS})
string(TOLOWER ${app} binary_name)
list(APPEND BENTO4_APPS_LOWERCASE ${binary_name})
add_executable(${binary_name} ${SOURCE_ROOT}/Apps/${app}/${app}.cpp)
target_link_libraries(${binary_name} ap4)
endforeach()

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)

set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}Config.cmake")

set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(NAMESPACE "${PROJECT_NAME}::")

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${VERSION_CONFIG}" COMPATIBILITY ExactVersion
)

configure_package_config_file(
"cmake/Config.cmake.in"
"${PROJECT_CONFIG}"
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
)

install(
TARGETS ap4 ${BENTO4_APPS_LOWERCASE}
EXPORT "${TARGETS_EXPORT_NAME}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(
FILES ${AP4_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)

install(
FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}"
DESTINATION "${CONFIG_INSTALL_DIR}"
)

install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${NAMESPACE}"
DESTINATION "${CONFIG_INSTALL_DIR}"
)
16 changes: 16 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2016, Ruslan Baratov
#
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://opensource.org/licenses/MIT
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")