mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-29 18:37:41 +08:00
optimize cmake for Android Studio that can use c++_shared and gnustl_shared
This commit is contained in:
parent
a94862962c
commit
6aeeb6dc8c
@ -10,7 +10,7 @@
|
||||
</facet>
|
||||
<facet type="native-android-gradle" name="Native-Android-Gradle">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug-x86" />
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug-armeabi" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
@ -25,7 +25,7 @@
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
||||
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" />
|
||||
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
<option name="PROJECT_TYPE" value="1" />
|
||||
</configuration>
|
||||
|
@ -36,13 +36,8 @@ android {
|
||||
//arguments "-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
arguments "-DACL_CLIENT_ONLY=YES"
|
||||
//cppFlags "-fexceptions"
|
||||
//abiFilters 'armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86'
|
||||
//abiFilters 'x86', 'arm64-v8a'
|
||||
//abiFilters 'arm64-v8a'
|
||||
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64', 'armeabi'
|
||||
//abiFilters 'armeabi'
|
||||
//abiFilters 'arm64-v8a', 'armeabi-v7a'
|
||||
//abiFilters 'armeabi-v7a'
|
||||
//abiFilters 'armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
||||
abiFilters 'armeabi', 'arm64-v8a', 'armeabi-v7a'
|
||||
}
|
||||
cmake {
|
||||
//arguments '-DANDROID_PLATFORM=android-14','-DANDROID_TOOLCHAIN=clang'
|
||||
|
@ -10,13 +10,18 @@ if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-O3 -flto")
|
||||
# xxx: -flto can't be used on NDK with gnustl_shared
|
||||
if (ANDROID_STL MATCHES "gnustl_shared")
|
||||
add_definitions("-Oz")
|
||||
else()
|
||||
add_definitions("-O3 -flto")
|
||||
endif()
|
||||
add_definitions("-DANDROID")
|
||||
add_definitions("-DACL_CLIENT_ONLY")
|
||||
add_definitions("-Wno-invalid-source-encoding")
|
||||
add_definitions("-fdata-sections -ffunction-sections")
|
||||
add_definitions("-Wno-unused-command-line-argument")
|
||||
string(APPEND CMAKE_C_FLAGS " -Qunused-arguments")
|
||||
string(APPEND CMAKE_C_FLAGS "-Qunused-arguments")
|
||||
set(UNIX_OS true)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
add_definitions("-O2")
|
||||
@ -160,9 +165,10 @@ SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "acl")
|
||||
link_directories(${lib_output_path})
|
||||
|
||||
if (${UNIX_OS})
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -O3 -flto")
|
||||
target_compile_options(acl_static PRIVATE
|
||||
-fvisibility=hidden)
|
||||
if (NOT ANDROID_STL MATCHES "gnustl_shared")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -O3 -flto")
|
||||
endif()
|
||||
target_compile_options(acl_static PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
add_library(acl SHARED ${lib_src})
|
||||
|
@ -8,12 +8,19 @@ endif()
|
||||
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-O3 -flto")
|
||||
# xxx: -flto can't be used on NDK with gnustl_shared
|
||||
if (ANDROID_STL MATCHES "gnustl_shared")
|
||||
add_definitions("-Oz")
|
||||
else()
|
||||
add_definitions("-O3 -flto")
|
||||
endif()
|
||||
|
||||
add_definitions("-DANDROID")
|
||||
add_definitions("-Wno-unused-command-line-argument")
|
||||
add_definitions("-Wno-invalid-source-encoding")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -Qunused-arguments")
|
||||
set(UNIX_OS true)
|
||||
add_definitions("-fdata-sections -ffunction-sections")
|
||||
string(APPEND CMAKE_CXX_FLAGS "-Qunused-arguments")
|
||||
set(UNIX_OS true)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
add_definitions("-Wno-invalid-source-encoding")
|
||||
add_definitions("-O2")
|
||||
@ -201,10 +208,11 @@ SET_TARGET_PROPERTIES(acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
|
||||
link_directories(${lib_output_path})
|
||||
|
||||
if (${UNIX_OS})
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -lz -O3 -flto")
|
||||
if (NOT ANDROID_STL MATCHES "gnustl_shared")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -lz -O3 -flto")
|
||||
endif()
|
||||
target_compile_options(acl_cpp_static PRIVATE
|
||||
-fvisibility=hidden
|
||||
-fvisibility-inlines-hidden)
|
||||
-fvisibility=hidden -fvisibility-inlines-hidden)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
@ -212,11 +220,12 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
"${lib_output_path}/libprotocol.a ${lib_output_path}/libacl.a -liconv -lz -lpthread")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
elseif (${UNIX_OS})
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"${lib_output_path}/libprotocol.a ${lib_output_path}/libacl.a -lz -lpthread")
|
||||
if (NOT ANDROID_STL MATCHES "gnustl_shared")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"${lib_output_path}/libprotocol.a ${lib_output_path}/libacl.a -lz -lpthread")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(acl_cpp SHARED ${lib_src})
|
||||
target_link_libraries(acl_cpp protocol acl)
|
||||
|
@ -8,12 +8,17 @@ endif()
|
||||
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-O3 -flto")
|
||||
# xxx: -flto can't be used on NDK with gnustl_shared
|
||||
if (ANDROID_STL MATCHES "gnustl_shared")
|
||||
add_definitions("-Oz")
|
||||
else()
|
||||
add_definitions("-O3 -flto")
|
||||
endif()
|
||||
add_definitions("-DANDROID")
|
||||
add_definitions("-Wno-invalid-source-encoding")
|
||||
add_definitions("-Wno-unused-command-line-argument")
|
||||
add_definitions("-fdata-sections -ffunction-sections")
|
||||
string(APPEND CMAKE_C_FLAGS " -Qunused-arguments")
|
||||
string(APPEND CMAKE_C_FLAGS "-Qunused-arguments")
|
||||
set(UNIX_OS true)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
add_definitions("-O2")
|
||||
@ -116,14 +121,14 @@ SET_TARGET_PROPERTIES(protocol_static PROPERTIES OUTPUT_NAME "protocol")
|
||||
link_directories(${lib_output_path})
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -O3 -flto")
|
||||
target_compile_options(protocol_static PRIVATE
|
||||
-fvisibility=hidden)
|
||||
if (NOT ANDROID_STL MATCHES "gnustl_shared")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -O3 -flto")
|
||||
endif()
|
||||
target_compile_options(protocol_static PRIVATE -fvisibility=hidden)
|
||||
elseif (${UNIX_OS})
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -O3 -flto")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${lib_output_path}/libacl.a")
|
||||
target_compile_options(protocol_static PRIVATE
|
||||
-fvisibility=hidden)
|
||||
target_compile_options(protocol_static PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
Loading…
Reference in New Issue
Block a user