Skip to content

Commit

Permalink
CMakeLists.txt: install version.h and arch.h with HEADERS_ONLY
Browse files Browse the repository at this point in the history
Add note to README.md about how to ensure version.h gets generated.
  • Loading branch information
qyot27 committed Feb 14, 2022
1 parent 3d76f69 commit 0e58337
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion CMakeLists.txt
Expand Up @@ -355,13 +355,31 @@ endif()

else()

project(AviSynth-Headers VERSION ${version_major}.${version_minor}.${version_bugfix} LANGUAGES)
project(AviSynth-Headers VERSION ${version_major}.${version_minor}.${version_bugfix} LANGUAGES CXX)
message(STATUS "Install Only Headers: ON")

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/avs_core/include")
add_library(AviSynth::Headers ALIAS ${PROJECT_NAME})

# Determine target architecture
include("${CMAKE_CURRENT_LIST_DIR}/avs_core/TargetArch.cmake")
target_architecture(AVS_ARCH)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/avs_core/core/arch.h.in ${CMAKE_CURRENT_BINARY_DIR}/arch.h @ONLY)

# Dynamically generate the sequential version info from Git
# Based on the example here: http://www.cmake.org/pipermail/cmake/2010-July/038015.html
FIND_PACKAGE(Git)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_TARGET(
VersionGen
${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/avs_core/core/version.h.in
-D DST=${CMAKE_CURRENT_BINARY_DIR}/version.h
-D GIT=${GIT_EXECUTABLE}
-D REPO=${CMAKE_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/avs_core/Version.cmake
)

include(GNUInstallDirs)

install(
Expand All @@ -375,6 +393,13 @@ else()
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/avisynth
)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/version.h"
"${CMAKE_CURRENT_BINARY_DIR}/arch.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/avisynth/avs"
)


endif()

# uninstall target
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -61,7 +61,7 @@ using CMake to do a limited install as well.

> mkdir avisynth-build && cd avisynth-build
> <br>cmake ../ -DHEADERS_ONLY:bool=on
> <br>make install
> <br>make VersionGen install
`-DCMAKE_INSTALL_PREFIX` can be used to override the
install location if need be.
Expand Down

0 comments on commit 0e58337

Please sign in to comment.