Optimize building process by cmake on Windows platforms.

This commit is contained in:
郑树新 2024-08-31 21:10:21 +08:00
parent db529f4ca5
commit b19af9809d
8 changed files with 154 additions and 44 deletions

View File

@ -1,6 +1,7 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
project(Acl)
#cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.22.0)
project(acl)
#message(${CMAKE_SYSTEM_NAME})

View File

@ -1,5 +1,5 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.2.0)
#cmake_minimum_required(VERSION 2.8.0)
project(acl)
#set(CMAKE_BUILD_TYPE Release)
@ -166,6 +166,9 @@ elseif (${WIN_OS})
"-D_WINSOCK_DEPRECATED_NO_WARNINGS"
"-DACL_WRITEABLE_CHECK"
"-DACL_PREPARE_COMPILE")
if (ACL_BUILD_SHARED MATCHES "YES")
add_definitions("-DACL_DLL -DACL_EXPORTS")
endif()
endif()
if (ACL_CLIENT_ONLY MATCHES "YES")
@ -187,9 +190,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${acl_output_path})
add_library(acl_static STATIC ${acl_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "libacl")
set_target_properties(acl_static PROPERTIES OUTPUT_NAME "libacl")
set_target_properties(acl_static PROPERTIES
OUTPUT_NAME "libacl"
ARCHIVE_OUTPUT_DIRECTORY ${acl_output_path}/static
LIBRARY_OUTPUT_DIRECTORY ${acl_output_path}/static
)
else()
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "acl")
set_target_properties(acl_static PROPERTIES OUTPUT_NAME "acl")
endif()
link_directories(${acl_output_path})
@ -234,9 +242,15 @@ if (ACL_BUILD_SHARED MATCHES "YES")
add_library(acl_shared SHARED ${acl_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(acl_shared PROPERTIES OUTPUT_NAME "libacl")
set_target_properties(acl_shared PROPERTIES
OUTPUT_NAME "libacl"
RUNTIME_OUTPUT_DIRECTORY ${acl_output_path}/shared
ARCHIVE_OUTPUT_DIRECTORY ${acl_output_path}/shared
LIBRARY_OUTPUT_DIRECTORY ${acl_output_path}/shared
)
set_target_properties(acl_shared PROPERTIES OUTPUT_NAME "libacl")
else()
SET_TARGET_PROPERTIES(acl_shared PROPERTIES OUTPUT_NAME "acl")
set_target_properties(acl_shared PROPERTIES OUTPUT_NAME "acl")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")

View File

@ -1,5 +1,5 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.2.0)
#cmake_minimum_required(VERSION 2.8.0)
project(acl_cpp)
#set(CMAKE_BUILD_TYPE Release)
@ -238,6 +238,11 @@ elseif (${WIN_OS})
"-DHAS_POLARSSL_DLL"
"-DHAS_MBEDTLS_DLL"
"-DUSE_WIN_ICONV")
if (ACL_BUILD_SHARED MATCHES "YES")
add_definitions("-DACL_CPP_DLL -DACL_CPP_EXPORTS"
"-DACL_DLL -DHTTP_DLL -DICMP_DLL -DSMTP_DLL"
)
endif()
aux_source_directory(${src}/stdlib/internal lib_src)
endif()
@ -255,9 +260,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
add_library(acl_cpp_static STATIC ${lib_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(acl_cpp_static PROPERTIES OUTPUT_NAME "libacl_cpp")
set_target_properties(acl_cpp_static PROPERTIES
OUTPUT_NAME "libacl_cpp"
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/static
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/static
)
else()
SET_TARGET_PROPERTIES(acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
set_target_properties(acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
endif()
link_directories(${lib_output_path})
@ -302,12 +311,26 @@ if (ACL_BUILD_SHARED MATCHES "YES")
-fvisibility=hidden -fvisibility-inlines-hidden)
endif()
set(lc_flags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}")
add_library(acl_cpp_shared SHARED ${lib_src})
target_link_libraries(acl_cpp_shared protocol acl)
if (${WIN_OS})
link_directories(${lib_output_path}/shared)
endif()
SET_TARGET_PROPERTIES(acl_cpp_shared PROPERTIES OUTPUT_NAME "acl_cpp")
add_library(acl_cpp_shared SHARED ${lib_src})
if (${WIN_OS})
set_target_properties(acl_cpp_shared PROPERTIES
OUTPUT_NAME "libacl_cpp"
RUNTIME_OUTPUT_DIRECTORY ${lib_output_path}/shared
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/shared
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/shared
)
target_link_libraries(acl_cpp_shared libprotocol libacl)
else()
set(lc_flags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}")
set_target_properties(acl_cpp_shared PROPERTIES OUTPUT_NAME "acl_cpp")
target_link_libraries(acl_cpp_shared protocol acl)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(TARGETS acl_cpp_shared

View File

@ -1,5 +1,5 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.2.0)
#cmake_minimum_required(VERSION 2.8.0)
project(fiber)
#set(CMAKE_BUILD_TYPE Release)
@ -82,6 +82,9 @@ elseif (${WIN_OS})
"-DACL_WRITEABLE_CHECK"
"-D_CRT_SECURE_NO_WARNINGS"
"-DACL_PREPARE_COMPILE")
if (ACL_BUILD_SHARED MATCHES "YES")
add_definitions("-DFIBER_DLL -DFIBER_EXPORTS")
endif()
endif()
#if (CMAKE_BUILD_TYPE STREQUAL "")
@ -148,9 +151,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
add_library(fiber_static STATIC ${lib_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(fiber_static PROPERTIES OUTPUT_NAME "libfiber")
set_target_properties(fiber_static PROPERTIES
OUTPUT_NAME "libfiber"
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/static
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/static
)
else()
SET_TARGET_PROPERTIES(fiber_static PROPERTIES OUTPUT_NAME "fiber")
set_target_properties(fiber_static PROPERTIES OUTPUT_NAME "fiber")
endif()
link_directories(${lib_output_path})
@ -188,9 +195,24 @@ if (ACL_BUILD_SHARED MATCHES "YES")
endif()
endif()
set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}")
if (${WIN_OS})
link_directories(${lib_output_path}/shared)
endif()
add_library(fiber_shared SHARED ${lib_src})
SET_TARGET_PROPERTIES(fiber_shared PROPERTIES OUTPUT_NAME "fiber")
if (${WIN_OS})
set_target_properties(fiber_shared PROPERTIES
OUTPUT_NAME "libfiber"
RUNTIME_OUTPUT_DIRECTORY ${lib_output_path}/shared
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/shared
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/shared
)
set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}")
else()
set_target_properties(fiber_shared PROPERTIES OUTPUT_NAME "fiber")
set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(TARGETS fiber_shared

View File

@ -1,5 +1,5 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.2.0)
#cmake_minimum_required(VERSION 2.8.0)
project(fiber_cpp)
#set(CMAKE_BUILD_TYPE Release)
@ -72,6 +72,11 @@ elseif (${WIN_OS})
"-D_WINSOCK_DEPRECATED_NO_WARNINGS"
"-DACL_WRITEABLE_CHECK"
"-DACL_PREPARE_COMPILE")
if (ACL_BUILD_SHARED MATCHES "YES")
add_definitions("-DFIBER_CPP_DLL -DFIBER_CPP_EXPORTS"
"-DACL_DLL -DHTTP_DLL -DICMP_DLL -DSMTP_DLL -DACL_CPP_DLL -DFIBER_DLL"
)
endif()
endif()
#if (CMAKE_BUILD_TYPE STREQUAL "")
@ -111,7 +116,7 @@ include_directories(
)
if (${WIN_OS})
set(sources ${src})
set(sources ${src} ${src}/detours)
else()
set(sources ${src} ${src}/keeper)
endif()
@ -135,9 +140,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
add_library(fiber_cpp_static STATIC ${lib_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(fiber_cpp_static PROPERTIES OUTPUT_NAME "libfiber_cpp")
set_target_properties(fiber_cpp_static PROPERTIES
OUTPUT_NAME "libfiber_cpp"
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/static
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/static
)
else()
SET_TARGET_PROPERTIES(fiber_cpp_static PROPERTIES OUTPUT_NAME "fiber_cpp")
set_target_properties(fiber_cpp_static PROPERTIES OUTPUT_NAME "fiber_cpp")
endif()
link_directories(${lib_output_path})
@ -178,12 +187,27 @@ if (ACL_BUILD_SHARED MATCHES "YES")
-fvisibility=hidden -fvisibility-inlines-hidden)
endif()
set(lc_ldflags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_ldflags} ${sys_ldflags}")
add_library(fiber_cpp_shared SHARED ${lib_src})
target_link_libraries(fiber_cpp_shared acl_cpp protocol acl fiber)
if (${WIN_OS})
link_directories(${lib_output_path}/shared)
endif()
SET_TARGET_PROPERTIES(fiber_cpp_shared PROPERTIES OUTPUT_NAME "fiber_cpp")
add_library(fiber_cpp_shared SHARED ${lib_src})
if (${WIN_OS})
set_target_properties(fiber_cpp_shared PROPERTIES
OUTPUT_NAME "libfiber_cpp"
RUNTIME_OUTPUT_DIRECTORY ${lib_output_path}/shared
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/shared
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/shared
)
set(CMAKE_SHARED_LINKER_FLAGS "${lc_ldflags} ${sys_ldflags}")
target_link_libraries(fiber_cpp_shared libacl_cpp libprotocol libacl libfiber Ws2_32)
else()
set_target_properties(fiber_cpp_shared PROPERTIES OUTPUT_NAME "fiber_cpp")
set(lc_ldflags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_ldflags} ${sys_ldflags}")
target_link_libraries(fiber_cpp_shared acl_cpp protocol acl fiber)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(TARGETS fiber_cpp_shared

View File

@ -467,7 +467,7 @@ static BOOL RecordExeRestore(HANDLE hProcess, HMODULE hModule, DETOUR_EXE_RESTOR
#define IMAGE_THUNK_DATAXX IMAGE_THUNK_DATA32
#define UPDATE_IMPORTS_XX UpdateImports32
#define DETOURS_BITS_XX 32
#include "uimports.cpp"
#include "deps/uimports.cpp"
#undef DETOUR_EXE_RESTORE_FIELD_XX
#undef DWORD_XX
#undef IMAGE_NT_HEADERS_XX
@ -484,7 +484,7 @@ static BOOL RecordExeRestore(HANDLE hProcess, HMODULE hModule, DETOUR_EXE_RESTOR
#define IMAGE_THUNK_DATAXX IMAGE_THUNK_DATA64
#define UPDATE_IMPORTS_XX UpdateImports64
#define DETOURS_BITS_XX 64
#include "uimports.cpp"
#include "deps/uimports.cpp"
#undef DETOUR_EXE_RESTORE_FIELD_XX
#undef DWORD_XX
#undef IMAGE_NT_HEADERS_XX

View File

@ -1,5 +1,5 @@
#cmake_minimum_required(VERSION 3.2.0)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.2.0)
#cmake_minimum_required(VERSION 2.8.0)
project(protocol)
#set(CMAKE_BUILD_TYPE Release)
@ -119,6 +119,13 @@ elseif (${WIN_OS})
"-D_WINSOCK_DEPRECATED_NO_WARNINGS"
"-DACL_WRITEABLE_CHECK"
"-DACL_PREPARE_COMPILE")
if (ACL_BUILD_SHARED MATCHES "YES")
add_definitions("-DHTTP_DLL -DHTTP_EXPORTS"
"-DICMP_DLL -DICMP_EXPORTS"
"-DSMTP_DLL -DSMTP_EXPORTS"
"-DACL_DLL"
)
endif()
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
@ -135,9 +142,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
add_library(protocol_static STATIC ${lib_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(protocol_static PROPERTIES OUTPUT_NAME "libprotocol")
set_target_properties(protocol_static PROPERTIES
OUTPUT_NAME "libprotocol"
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/static
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/static
)
else()
SET_TARGET_PROPERTIES(protocol_static PROPERTIES OUTPUT_NAME "protocol")
set_target_properties(protocol_static PROPERTIES OUTPUT_NAME "protocol")
endif()
link_directories(${lib_output_path})
@ -178,12 +189,27 @@ if (ACL_BUILD_SHARED MATCHES "YES")
endif()
endif()
set(lc_flags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}")
add_library(protocol_shared SHARED ${lib_src})
target_link_libraries(protocol_shared acl)
if (${WIN_OS})
link_directories(${lib_output_path}/shared)
endif()
SET_TARGET_PROPERTIES(protocol_shared PROPERTIES OUTPUT_NAME "protocol")
add_library(protocol_shared SHARED ${lib_src})
if (${WIN_OS})
set_target_properties(protocol_shared PROPERTIES
OUTPUT_NAME "libprotocol"
RUNTIME_OUTPUT_DIRECTORY ${lib_output_path}/shared
ARCHIVE_OUTPUT_DIRECTORY ${lib_output_path}/shared
LIBRARY_OUTPUT_DIRECTORY ${lib_output_path}/shared
)
set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}")
target_link_libraries(protocol_shared libacl Ws2_32)
else()
set_target_properties(protocol_shared PROPERTIES OUTPUT_NAME "protocol")
set(lc_flags "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${lib_output_path}")
set(CMAKE_SHARED_LINKER_FLAGS "${lc_flags} ${sys_ldflags}")
target_link_libraries(protocol_shared acl)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(TARGETS protocol_shared