summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-14 12:56:19 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-14 12:56:19 (GMT)
commitb93623550dceac981aa4cc49f9e892c497aee49a (patch)
tree3b996cd7de25624e2157237cc88bca92a5ffa89f /Tests
parent35e3836589535bae12208a403011c7e95e589a85 (diff)
parent42ce9f1e7178b3535726c0c885cc7c9f760cc8b6 (diff)
downloadCMake-b93623550dceac981aa4cc49f9e892c497aee49a.zip
CMake-b93623550dceac981aa4cc49f9e892c497aee49a.tar.gz
CMake-b93623550dceac981aa4cc49f9e892c497aee49a.tar.bz2
Merge topic 'add_androidmk_generator'
42ce9f1e Add support for creating prebuilt Android.mk files d5257063 Export: Virtualize file generation step helpers f81b9475 Export: Factor out file generation steps into helpers
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/AndroidMK/AndroidMK-check.cmake30
-rw-r--r--Tests/RunCMake/AndroidMK/AndroidMK.cmake11
-rw-r--r--Tests/RunCMake/AndroidMK/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/AndroidMK/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt23
-rw-r--r--Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt25
-rw-r--r--Tests/RunCMake/AndroidMK/foo.cxx3
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
8 files changed, 99 insertions, 0 deletions
diff --git a/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake
new file mode 100644
index 0000000..691e326
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake
@@ -0,0 +1,30 @@
+# This file does a regex file compare on the generated
+# Android.mk files from the AndroidMK test
+
+macro(compare_file_to_expected file expected_file)
+ file(READ "${file}" ANDROID_MK)
+ # clean up new lines
+ string(REGEX REPLACE "\r\n" "\n" ANDROID_MK "${ANDROID_MK}")
+ string(REGEX REPLACE "\n+$" "" ANDROID_MK "${ANDROID_MK}")
+ # read in the expected regex file
+ file(READ "${expected_file}" expected)
+ # clean up new lines
+ string(REGEX REPLACE "\r\n" "\n" expected "${expected}")
+ string(REGEX REPLACE "\n+$" "" expected "${expected}")
+ # compare the file to the expected regex and if there is not a match
+ # put an error message in RunCMake_TEST_FAILED
+ if(NOT "${ANDROID_MK}" MATCHES "${expected}")
+ set(RunCMake_TEST_FAILED
+ "${file} does not match ${expected_file}:
+
+Android.mk contents = [\n${ANDROID_MK}\n]
+Expected = [\n${expected}\n]")
+ endif()
+endmacro()
+
+compare_file_to_expected(
+"${RunCMake_BINARY_DIR}/AndroidMK-build/Android.mk"
+"${RunCMake_TEST_SOURCE_DIR}/expectedBuildAndroidMK.txt")
+compare_file_to_expected(
+"${RunCMake_BINARY_DIR}/AndroidMK-build/CMakeFiles/Export/share/ndk-modules/Android.mk"
+"${RunCMake_TEST_SOURCE_DIR}/expectedInstallAndroidMK.txt")
diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake
new file mode 100644
index 0000000..ed21e58
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake
@@ -0,0 +1,11 @@
+project(build)
+set(CMAKE_BUILD_TYPE Debug)
+add_library(foo foo.cxx)
+add_library(car foo.cxx)
+add_library(bar foo.cxx)
+add_library(dog foo.cxx)
+target_link_libraries(foo car bar dog debug -lm)
+export(TARGETS bar dog car foo ANDROID_MK
+ ${build_BINARY_DIR}/Android.mk)
+install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp)
+install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules)
diff --git a/Tests/RunCMake/AndroidMK/CMakeLists.txt b/Tests/RunCMake/AndroidMK/CMakeLists.txt
new file mode 100644
index 0000000..576787a
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE) # or languages needed
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake b/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake
new file mode 100644
index 0000000..786d45b
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake
@@ -0,0 +1,2 @@
+include(RunCMake)
+run_cmake(AndroidMK)
diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt
new file mode 100644
index 0000000..def8fcb
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt
@@ -0,0 +1,23 @@
+LOCAL_PATH.*call my-dir.*
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*bar
+LOCAL_SRC_FILES.*bar.*
+include.*PREBUILT_STATIC_LIBRARY.*
+.*
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*dog
+LOCAL_SRC_FILES.*.*dog.*
+include.*PREBUILT_STATIC_LIBRARY.*
+.*
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*car
+LOCAL_SRC_FILES.*.*car.*
+include.*PREBUILT_STATIC_LIBRARY.*
+.*
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*foo
+LOCAL_SRC_FILES.*.*foo.*
+LOCAL_CPP_FEATURES.*rtti exceptions
+LOCAL_STATIC_LIBRARIES.*car bar dog
+LOCAL_EXPORT_LDLIBS := -lm
+include.*PREBUILT_STATIC_LIBRARY.*
diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt
new file mode 100644
index 0000000..1bdb308
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt
@@ -0,0 +1,25 @@
+LOCAL_PATH.*call my-dir.*
+_IMPORT_PREFIX.*LOCAL_PATH./../..
+
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*bar
+LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*bar.*
+include.*PREBUILT_STATIC_LIBRARY.*
+
+include.*CLEAR_VARS.
+LOCAL_MODULE.*dog
+LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*dog.*
+include.*PREBUILT_STATIC_LIBRARY.*
+
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*car
+LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*car.*
+include.*PREBUILT_STATIC_LIBRARY.*
+
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*foo
+LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo.*
+LOCAL_CPP_FEATURES.*rtti exceptions
+LOCAL_STATIC_LIBRARIES.*car bar dog
+LOCAL_EXPORT_LDLIBS := -lm
+include.*PREBUILT_STATIC_LIBRARY.*
diff --git a/Tests/RunCMake/AndroidMK/foo.cxx b/Tests/RunCMake/AndroidMK/foo.cxx
new file mode 100644
index 0000000..3695dc9
--- /dev/null
+++ b/Tests/RunCMake/AndroidMK/foo.cxx
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index fa3d0f9..e36b2a6 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -331,6 +331,8 @@ add_RunCMake_test_group(CPack "DEB;RPM;TGZ")
# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
add_RunCMake_test(AutoExportDll)
+add_RunCMake_test(AndroidMK)
+
if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN)
if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
message(FATAL_ERROR "Android tests supported only by Makefile and Ninja generators")