Skip to content

Commit

Permalink
feat: build installer without ALL build
Browse files Browse the repository at this point in the history
Signed-off-by: Dylan <[email protected]>
  • Loading branch information
nmgwddj committed Oct 12, 2024
1 parent 5453e6d commit 09ba1d3
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 149 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,28 @@ jobs:
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.65.0

- name: Fetch all tags
run: git fetch --tags --prune --unshallow --force

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{env.GITHUB_WORKSPACE}}/build -AWin32 -T"v141_xp" -DCMAKE_BUILD_TYPE=${{env.BUILD_CONFIGURATION}}
run: cmake -B ${{env.GITHUB_WORKSPACE}}/build -AWin32 -DCMAKE_BUILD_TYPE=${{env.BUILD_CONFIGURATION}}

- name: Build nim demo
- name: Build nim-demo
# Build your program with the given configuration
run: cmake --build ${{env.GITHUB_WORKSPACE}}/build --config ${{env.BUILD_CONFIGURATION}} --target install
run: cmake --build ${{env.GITHUB_WORKSPACE}}/build --config ${{env.BUILD_CONFIGURATION}}

- name: Configure nim demo installer
run: cmake tool_kits -B ${{env.GITHUB_WORKSPACE}}/build_setup -AWin32 -T"v141_xp" -DCMAKE_BUILD_TYPE=${{env.BUILD_CONFIGURATION}}

- name: Build nim demo installer
run: cmake --build ${{env.GITHUB_WORKSPACE}}/build_setup --config ${{env.BUILD_CONFIGURATION}} --target installer
- name: Build nim-demo installer
run: cmake --build ${{env.GITHUB_WORKSPACE}}/build --config ${{env.BUILD_CONFIGURATION}} --target installer

- uses: actions/upload-artifact@v2
with:
name: PC_Demo_Setup
path: tool_kits/install/bin/*.exe
# - uses: actions/upload-artifact@v2
# with:
# name: PC_Demo_Setup
# path: tool_kits/install/bin/*.exe
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.19)

set(CMAKE_CXX_STANDARD 14)

Expand All @@ -14,11 +14,6 @@ else ()
add_definitions(-DSUPPORTLOCALPLAYER)
endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/pdb")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/pdb")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake")
Expand All @@ -38,6 +33,7 @@ if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/.cmake/conan.cmake")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" "${CMAKE_CURRENT_LIST_DIR}/.cmake/conan.cmake")
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/.cmake/conan.cmake)
conan_add_remote(NAME yunxin URL https://gitlab.com/api/v4/projects/47777150/packages/conan)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .. BUILD missing SETTINGS ${settings})
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Expand Down Expand Up @@ -81,6 +77,11 @@ include_directories(

file(GLOB_RECURSE THIRD_PARTY_LIBS ${CMAKE_CURRENT_LIST_DIR}/lib/*.lib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_LIST_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/pdb")
set(CMAKE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_LIST_DIR}/pdb")

add_subdirectory(chatroom)
add_subdirectory(tool_kits/base)
add_subdirectory(tool_kits/duilib)
Expand All @@ -98,5 +99,6 @@ add_subdirectory(tool_kits/cef/cef_render)
add_subdirectory(app_sdk)
add_subdirectory(nim_win_demo)
add_subdirectory(tool_kits/uninstall)
add_subdirectory(tool_kits/install)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT nim_demo)
1 change: 0 additions & 1 deletion nim_win_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ configure_file(
${CMAKE_CURRENT_LIST_DIR}/nim.rc.in
${CMAKE_BINARY_DIR}/nim.rc
)

file(GLOB_RECURSE NIM_DEMO_SOURCE *.cc *.h *.cpp *.c)

add_executable(${PROJECT_NAME} ${NIM_DEMO_SOURCE} ${CMAKE_BINARY_DIR}/nim.rc)
Expand Down
130 changes: 0 additions & 130 deletions tool_kits/CMakeLists.txt

This file was deleted.

83 changes: 83 additions & 0 deletions tool_kits/install/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

SET(CMAKE_CXX_STANDARD 11)

SET(RELEASE_OUTPUT_7Z_FILE ${CMAKE_BINARY_DIR}/release.7z)
STRING(REPLACE "/" "\\\\" RELEASE_OUTPUT_7Z_FILE_WIN ${RELEASE_OUTPUT_7Z_FILE})
SET(RESOURCE_OUTPUT_ZIP_FILE ${CMAKE_CURRENT_LIST_DIR}/resources.zip)
STRING(REPLACE "/" "\\\\" RESOURCE_OUTPUT_ZIP_FILE_WIN ${RESOURCE_OUTPUT_ZIP_FILE})

PROJECT(installer DESCRIPTION "NetEase IM Demo Installer")

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/tool_kits/
${CMAKE_SOURCE_DIR}/tool_kits/build/
${CMAKE_SOURCE_DIR}/tool_kits/install/
)

CONFIGURE_FILE(
${CMAKE_CURRENT_LIST_DIR}/setup.rc.in
${CMAKE_BINARY_DIR}/setup.rc
)

# pack release.7z for setup resource
ADD_CUSTOM_TARGET(pack_binaries
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${RELEASE_OUTPUT_7Z_FILE}" --format=7zip -- ${CMAKE_SOURCE_DIR}/bin
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
USES_TERMINAL
COMMENT "Packing release 7z files....... ${CMAKE_SOURCE_DIR}/bin"
)
SET_TARGET_PROPERTIES(pack_binaries PROPERTIES FOLDER "setup")

# pack resource.zip for setup resource
ADD_CUSTOM_TARGET(pack_install_res ALL
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${RESOURCE_OUTPUT_ZIP_FILE}" --format=zip -- ${CMAKE_CURRENT_LIST_DIR}/bin/resources
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin/
VERBATIM
USES_TERMINAL
COMMENT "Packing resources files....... ${CMAKE_CURRENT_LIST_DIR}/bin/resources"
)
SET_TARGET_PROPERTIES(pack_install_res PROPERTIES FOLDER "setup")

FILE(GLOB_RECURSE NIM_SETUP_SOURCE
${CMAKE_CURRENT_LIST_DIR}/*.cc
${CMAKE_CURRENT_LIST_DIR}/*.h
${CMAKE_CURRENT_LIST_DIR}/*.cpp
${CMAKE_CURRENT_LIST_DIR}/*.c
)
ADD_EXECUTABLE(
${PROJECT_NAME}
EXCLUDE_FROM_ALL
${NIM_SETUP_SOURCE}
${CMAKE_BINARY_DIR}/setup.rc
)

# set dependencies
ADD_DEPENDENCIES(${PROJECT_NAME} pack_install_res pack_binaries)

TARGET_LINK_LIBRARIES(${PROJECT_NAME}
base
duilib
shared
DbgHelp
Version
Netapi32
Snmpapi
Userenv
Ws2_32
Psapi
Iphlpapi
Imm32
Comctl32
User32
Vfw32
gdiplus
Msimg32
)

SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
FOLDER "setup"
LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS"
OUTPUT_NAME "NIM_Demo_Setup_${GIT_TAG}.${GIT_COMMIT_COUNT}"
)

0 comments on commit 09ba1d3

Please sign in to comment.