Optimize cmake building.

This commit is contained in:
zhengshuxin 2024-04-16 10:12:29 +08:00
parent a6d6a527c2
commit 37dada83f2
7 changed files with 45 additions and 28 deletions

View File

@ -82,15 +82,11 @@ endif()
add_subdirectory(lib_acl acl)
add_subdirectory(lib_protocol protocol)
add_subdirectory(lib_acl_cpp acl_cpp)
if (ACL_BUILD_SHARED MATCHES "YES")
add_dependencies(protocol_shared acl_shared)
add_dependencies(acl_cpp_shared protocol_shared acl_shared)
endif()
add_subdirectory(lib_fiber/c fiber)
add_subdirectory(lib_fiber/cpp fiber_cpp)
if (ACL_BUILD_SHARED MATCHES "YES")
add_dependencies(protocol_shared acl_shared)
add_dependencies(acl_cpp_shared protocol_shared acl_shared)
add_dependencies(fiber_cpp_shared acl_cpp_shared protocol_shared acl_shared fiber_shared)
endif()

View File

@ -1,7 +1,9 @@
#!/bin/sh
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/soft/acl -DACL_BUILD_SHARED=YES ..
cmake -DCMAKE_INSTALL_PREFIX=/opt/soft/acl -DACL_BUILD_SHARED=YES \
-DHAS_MYSQL_DLL=YES -DHAS_PGSQL_DLL=YES -DHAS_SQLITE_DLL=YES \
-DHAS_POLARSSL_DLL=YES -DHAS_MBEDTLS_DLL=YES -DHAS_OPENSSL_DLL=YES ..
#cmake -DACL_BUILD_SHARED=YES ..
make -j 4
make install

View File

@ -104,7 +104,10 @@ set(sources
)
foreach(iter ${sources})
aux_source_directory(${iter} lib_src)
if (ACL_BUILD_VERBOSE MATCHES "YES")
message(STATUS ">>add dir ${iter}")
endif()
aux_source_directory(${iter} acl_src)
endforeach()
##############################################################################
@ -171,17 +174,17 @@ if (ACL_CLIENT_ONLY MATCHES "YES")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI})
set(acl_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../android/lib/${ANDROID_ABI})
elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS")
set(lib_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../harmony/lib/${OHOS_ARCH})
set(acl_output_path ${CMAKE_CURRENT_SOURCE_DIR}/../harmony/lib/${OHOS_ARCH})
else()
set(lib_output_path ${PROJECT_BINARY_DIR}/../lib)
set(acl_output_path ${PROJECT_BINARY_DIR}/../lib)
endif()
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
set(LIBRARY_OUTPUT_PATH ${acl_output_path})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${acl_output_path})
add_library(acl_static STATIC ${lib_src})
add_library(acl_static STATIC ${acl_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "libacl")
@ -189,7 +192,7 @@ else()
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "acl")
endif()
link_directories(${lib_output_path})
link_directories(${acl_output_path})
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(TARGETS acl_static
@ -228,7 +231,7 @@ if (ACL_BUILD_SHARED MATCHES "YES")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "${sys_ldflags}")
add_library(acl_shared SHARED ${lib_src})
add_library(acl_shared SHARED ${acl_src})
if (${WIN_OS})
SET_TARGET_PROPERTIES(acl_shared PROPERTIES OUTPUT_NAME "libacl")
@ -244,5 +247,4 @@ if (ACL_BUILD_SHARED MATCHES "YES")
endif()
endif()
##############################################################################

View File

@ -125,6 +125,9 @@ set(sources
)
foreach(iter ${sources})
if (ACL_BUILD_VERBOSE MATCHES "YES")
message(STATUS ">>add dir ${iter}")
endif()
aux_source_directory(${iter} lib_src)
endforeach()
@ -197,26 +200,32 @@ if (${UNIX_OS})
if (HAS_POLARSSL MATCHES "YES")
add_definitions("-DHAS_POLARSSL")
message(STATUS "HAS_POLARSSL been set, polarssl enable!")
elseif (HAS_MBEDTLS MATCHES "YES")
add_definitions("-DHAS_MBEDTLS")
message(STATUS "HAS_MBEDTLS been set, mbedtls enable!")
elseif (HAS_OPENSSL MATCHES "YES")
add_definitions("-DHAS_OPENSSL")
message(STATUS "HAS_OPENSSL been set, openssl enable!")
elseif (HAS_POLARSSL_DLL MATCHES "YES")
add_definitions("-DHAS_POLARSSL_DLL")
message(STATUS "HAS_POLARSSL_DLL been set, polarssl enable!")
else()
message(STATUS "polarssl disable!")
endif()
if (HAS_MBEDTLS MATCHES "YES")
add_definitions("-DHAS_MBEDTLS")
message(STATUS "HAS_MBEDTLS been set, mbedtls enable!")
elseif (HAS_MBEDTLS_DLL MATCHES "YES")
add_definitions("-DHAS_MBEDTLS_DLL")
message(STATUS "HAS_MBEDTLS_DLL been set, mbedtls enable!")
else()
message(STATUS "mbedtls disable!")
endif()
if (HAS_OPENSSL MATCHES "YES")
add_definitions("-DHAS_OPENSSL")
message(STATUS "HAS_OPENSSL been set, openssl enable!")
elseif (HAS_OPENSSL_DLL MATCHES "YES")
add_definitions("-DHAS_OPENSSL_DLL")
message(STATUS "HAS_OPENSSL_DLL been set, openssl enable!")
else()
message(STATUS "SSL disable!")
message(STATUS "openssl disable!")
endif()
elseif (${WIN_OS})
add_definitions(
"-Ycacl_stdafx.hpp"

View File

@ -127,8 +127,10 @@ set(sources
)
foreach(iter ${sources})
aux_source_directory(${iter} lib_src)
if (ACL_BUILD_VERBOSE MATCHES "YES")
message(STATUS ">>add dir ${iter}")
endif()
aux_source_directory(${iter} lib_src)
endforeach()
list(APPEND lib_src ${src}/fiber/boost/make_gas.S

View File

@ -117,6 +117,9 @@ else()
endif()
foreach(iter ${sources})
if (ACL_BUILD_VERBOSE MATCHES "YES")
message(STATUS ">>add dir ${iter}")
endif()
aux_source_directory(${iter} lib_src)
endforeach()

View File

@ -75,6 +75,9 @@ set(sources
)
foreach (iter ${sources})
if (ACL_BUILD_VERBOSE MATCHES "YES")
message(STATUS ">>add dir ${iter}")
endif()
aux_source_directory(${iter} lib_src)
endforeach()