forked from the-mac/AndroidJniHelpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
60 lines (45 loc) · 1.95 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
cmake_minimum_required(VERSION 3.4.1)
set(library_JniHelpers_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp)
set(library_JniHelpersTest_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/androidTest/cpp)
file(GLOB libJniHelpers_SOURCES ${library_JniHelpers_DIR}/*.cpp)
file(GLOB libJniHelpers_HEADERS ${library_JniHelpers_DIR}/*.h)
file(GLOB libJniHelpersTest_SOURCES ${library_JniHelpersTest_DIR}/*.cpp)
file(GLOB libJniHelpersTest_HEADERS ${library_JniHelpersTest_DIR}/*.h)
link_directories(${JNI_LIBRARIES})
add_library(JniHelpers STATIC ${libJniHelpers_SOURCES})
add_library(JniHelpersTest STATIC ${libJniHelpers_SOURCES} ${libJniHelpersTest_SOURCES})
include_directories(${library_JniHelpers_DIR} ${library_JniHelpersTest_DIR})
if(${ANDROID_RELEASE})
set(library_NAME "jni-helper-lib")
set(library_Entry_Point "src/main/cpp")
else()
if(${ANDROID_TESTING})
set(library_NAME "test-helper-lib")
set(library_Entry_Point "src/androidTest/cpp")
else()
set(library_NAME "jni-helper-lib")
set(library_Entry_Point "src/main/cpp")
endif()
endif()
add_library( # Sets the name of the library.
${library_NAME}
# Sets the library as a shared library.
SHARED
# The following toggles between the native-lib and test-libs
# files, based upon whehther a test is currently running.
${library_Entry_Point}/${library_NAME}.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Only adding JniHelpersTest library if testing
if(${ANDROID_RELEASE})
target_link_libraries(${library_NAME} JniHelpers ${log-lib} )
else()
if(${ANDROID_TESTING})
target_link_libraries(${library_NAME} JniHelpers JniHelpersTest ${log-lib} )
else()
target_link_libraries(${library_NAME} JniHelpers ${log-lib} )
endif()
endif()