mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-12-05 19:05:26 +00:00
fix build using cmake with generating version info from git
This commit is contained in:
@@ -9,61 +9,57 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
find_package(Gettext REQUIRED)
|
||||
find_package(GD REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Intl REQUIRED)
|
||||
|
||||
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||
|
||||
# Configure names and versions
|
||||
execute_process(COMMAND bash "${CMAKE_CURRENT_LIST_DIR}/build-aux/git-version-gen" OUTPUT_VARIABLE VERSION)
|
||||
|
||||
# Configure project executable
|
||||
add_executable(ptouch-print)
|
||||
|
||||
target_sources(ptouch-print
|
||||
PUBLIC
|
||||
include/ptouch.h
|
||||
PRIVATE
|
||||
include/gettext.h
|
||||
src/libptouch.c
|
||||
src/ptouch-print.c
|
||||
target_sources(ptouch-print PUBLIC
|
||||
version.h
|
||||
include/ptouch.h
|
||||
include/gettext.h
|
||||
src/libptouch.c
|
||||
src/ptouch-print.c
|
||||
)
|
||||
|
||||
# Configure compiler
|
||||
target_compile_options(ptouch-print
|
||||
PRIVATE
|
||||
-g
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wunused
|
||||
-O3
|
||||
-fPIC
|
||||
target_compile_options(ptouch-print PUBLIC
|
||||
-g
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wunused
|
||||
-O3
|
||||
-fPIC
|
||||
)
|
||||
|
||||
target_compile_definitions(ptouch-print
|
||||
PRIVATE
|
||||
LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}"
|
||||
USING_CMAKE=1
|
||||
VERSION="${VERSION}"
|
||||
PACKAGE="ptouch"
|
||||
target_compile_definitions(ptouch-print PUBLIC
|
||||
LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}"
|
||||
USING_CMAKE=1
|
||||
PACKAGE="ptouch-print"
|
||||
)
|
||||
|
||||
target_include_directories(ptouch-print
|
||||
PRIVATE
|
||||
include
|
||||
${GD_INCLUDE_DIR}
|
||||
${LIBUSB_INCLUDE_DIRS}
|
||||
target_include_directories(ptouch-print PUBLIC
|
||||
include
|
||||
${GD_INCLUDE_DIR}
|
||||
${LIBUSB_INCLUDE_DIRS}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${Libintl_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Configure linker
|
||||
target_link_libraries(ptouch-print
|
||||
${GD_LIBRARIES}
|
||||
${LIBUSB_LIBRARIES}
|
||||
${GD_LIBRARIES}
|
||||
${LIBUSB_LIBRARIES}
|
||||
${Libintl_LIBRARY}
|
||||
)
|
||||
|
||||
# Add a custom command that produces version.cpp, plus
|
||||
# a dummy output that's not actually produced, in order
|
||||
# to force version.cmake to always be re-run before the build
|
||||
# Add a custom command that produces version.h, plus a dummy output that's
|
||||
# not produced, in order to force gitversion.cmake to always be re-run
|
||||
# before the build
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/version.h
|
||||
${CMAKE_BINARY_DIR}/_version.h
|
||||
COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake)
|
||||
|
||||
Reference in New Issue
Block a user