Skip to content

Commit

Permalink
Add install runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Sep 24, 2020
1 parent a3cb304 commit a68853c
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 18 deletions.
70 changes: 70 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Author: Kang Lin ([email protected])

cmake_minimum_required(VERSION 2.8.12)

if(POLICY CMP0100)
cmake_policy(SET CMP0100 NEW)
endif()

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

project(QZXing)

# TODO: Modify the version to the correct version
SET(BUILD_VERSION "2.3")
# Find Git Version Patch
IF(EXISTS "${CMAKE_SOURCE_DIR}/.git")
if(NOT GIT)
SET(GIT $ENV{GIT})
endif()
if(NOT GIT)
FIND_PROGRAM(GIT NAMES git git.exe git.cmd)
endif()
IF(GIT)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} describe --tags
OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_VERSION)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
SET(BUILD_VERSION ${GIT_VERSION})
ENDIF()
ENDIF()
message("BUILD_VERSION:${BUILD_VERSION}")
set(VERSION ${BUILD_VERSION})

# Open qt compile tools
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(GenerateExportHeader)

# Record the files that will need to be deleted
CONFIGURE_FILE(
"${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
# Create delete target
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")

SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libs")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()

add_subdirectory(src)
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ make install # Install
cd ${QZXing_DIR}
mkdir build
cd build
cmake ../src # Configure
cmake --build . # Compile
cmake --build . --target install # Install
# Configure
cmake ..
# Compile
cmake --build .
# Install
cmake --build . --target install # Install develop library
# or
cmake --build . --target install-runtime # Install runtime library
```

<a name="controlDependencies"></a>
Expand Down
File renamed without changes.
24 changes: 9 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,10 @@ include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(GenerateExportHeader)

# Record the files that will need to be deleted
CONFIGURE_FILE(
"cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
# Create delete target
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")

SET(BIGINT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zxing/bigint)
SET(WIN32_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zxing/win32/zxing)
SET(ZXING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zxing/zxing)

SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libs")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()

set(INSTALL_HEADER_FILES
QZXing.h
QZXing_global.h
Expand Down Expand Up @@ -174,6 +159,15 @@ target_include_directories(${PROJECT_NAME}
# Export defines by configure_file
target_compile_definitions(${PROJECT_NAME} PUBLIC ${EXPORT_DEFINES})

# Install

# Install runtime target
add_custom_target(install-runtime
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Runtime
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
)

if(ANDROID)
# Install target
INSTALL(TARGETS ${PROJECT_NAME}
Expand Down

0 comments on commit a68853c

Please sign in to comment.