diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b80c84ee..abaa00a6 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ef65d3e..91776b15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.19) set(CMAKE_CXX_STANDARD 14) @@ -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") @@ -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) @@ -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) @@ -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) diff --git a/nim_win_demo/CMakeLists.txt b/nim_win_demo/CMakeLists.txt index 43e07ee1..43f8b20c 100644 --- a/nim_win_demo/CMakeLists.txt +++ b/nim_win_demo/CMakeLists.txt @@ -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) diff --git a/tool_kits/CMakeLists.txt b/tool_kits/CMakeLists.txt deleted file mode 100644 index 57a6c40a..00000000 --- a/tool_kits/CMakeLists.txt +++ /dev/null @@ -1,130 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.10) - -SET(CMAKE_CXX_STANDARD 11) -SET(TARGET_NAME installer) - -IF (NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) - MESSAGE(STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}") -ENDIF () - -IF (CMAKE_BUILD_TYPE MATCHES "Release") - ADD_DEFINITIONS(-DNDEBUG) -ENDIF () - -SET(CONAN_DISABLE_CHECK_COMPILER ON) -SET(CMAKE_INCLUDE_CURRENT_DIR ON) -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_LIST_DIR}/install/bin") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/install/bin") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Gm- /Zi /MT") -SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") -SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") -SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) -SET_PROPERTY(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake") -ADD_COMPILE_OPTIONS("$<$:/utf-8>") -ADD_COMPILE_OPTIONS("$<$:/utf-8>") - -# Custom vars -SET(GROUP_BASE "base") -SET(GROUP_UI_COMPONENTS "ui_component") -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_SOURCE_DIR}/install/resources.zip) -STRING(REPLACE "/" "\\\\" RESOURCE_OUTPUT_ZIP_FILE_WIN ${RESOURCE_OUTPUT_ZIP_FILE}) - -PROJECT(${TARGET_NAME} DESCRIPTION "NetEase IM Demo Installer") - -ADD_DEFINITIONS( - -DUNICODE - -D_UNICODE - -DPSAPI_VERSION=1 -) - -# Git information -LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/") -INCLUDE(GetGitRevisionDescription) -git_release_version(GIT_TAG) -IF (GIT_TAG STREQUAL "") - git_latest_tag(GIT_TAG) -ENDIF () -IF ("${GIT_TAG}" STREQUAL "HEAD-HASH-NOTFOUND") - SET(GIT_TAG "0.0.0") -ENDIF () -git_describe(GIT_DESCRIBE) -git_commit_counts(GIT_COMMIT_COUNT) -STRING(REPLACE "." "," GIT_TAG_WITH_COMMA ${GIT_TAG}) -MESSAGE(STATUS "Current git tag: ${GIT_TAG}, commit count: ${GIT_COMMIT_COUNT}, describe: ${GIT_DESCRIBE}") - -# Depended third_party -ADD_SUBDIRECTORY(base) -ADD_SUBDIRECTORY(duilib) -ADD_SUBDIRECTORY(shared) -# ADD_SUBDIRECTORY(ui_component/ui_kit) - -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/install/ - ${CMAKE_CURRENT_SOURCE_DIR}/build/ -) - -CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/install/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_CURRENT_SOURCE_DIR}/../bin - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../ - VERBATIM - USES_TERMINAL - COMMENT "Packing release 7z files....... ${CMAKE_CURRENT_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_SOURCE_DIR}/install/bin/resources - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/install/bin/ - VERBATIM - USES_TERMINAL - COMMENT "Packing resources files....... ${CMAKE_CURRENT_SOURCE_DIR}/install/bin/resources" -) -SET_TARGET_PROPERTIES(pack_install_res PROPERTIES FOLDER "setup") - -FILE(GLOB_RECURSE NIM_SETUP_SOURCE install/*.cc install/*.h install/*.cpp install/*.c) -ADD_EXECUTABLE( - ${TARGET_NAME} - EXCLUDE_FROM_ALL - ${NIM_SETUP_SOURCE} - ${CMAKE_BINARY_DIR}/setup.rc -) - -# set dependencies -ADD_DEPENDENCIES(${TARGET_NAME} pack_install_res pack_binaries) - -TARGET_LINK_LIBRARIES(${TARGET_NAME} - base - duilib - shared - DbgHelp - Version - Netapi32 - Snmpapi - Userenv - Ws2_32 - Psapi - Iphlpapi - Imm32 - Comctl32 - User32 - Vfw32 - gdiplus - Msimg32 -) - -SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - FOLDER "setup" - LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS" - OUTPUT_NAME "NIM_Demo_Setup_${GIT_TAG}.${GIT_COMMIT_COUNT}" -) diff --git a/tool_kits/install/CMakeLists.txt b/tool_kits/install/CMakeLists.txt new file mode 100644 index 00000000..9ee918af --- /dev/null +++ b/tool_kits/install/CMakeLists.txt @@ -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}" +)