Skip to content

Commit

Permalink
update cmakelist.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Fimics committed Dec 26, 2019
1 parent ac4dd9c commit 45a6c2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
38 changes: 6 additions & 32 deletions demo-sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,12 @@ project(demo)
# # Links the target library to the log library
# # included in the NDK.
# ${log-lib})
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest)
add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc)
target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT})
target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()

# Now simply link against gtest or gtest_main as needed. Eg
add_executable(demo ./tests/HelloWorldTest.cpp)
target_link_libraries(demo gtest_main)
add_test(NAME demo COMMAND demo)
add_executable(footest ./tests/HelloWorldTest.cpp)
target_link_libraries(footest gtest)
2 changes: 1 addition & 1 deletion demo-sample/tests/HelloWorldTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include <gtest/gtest.h>
#include <stdio.h>
TEST(HelloWorldTest, add) {
TEST(HelloWorldTest, footest) {
int c = 3+5;
printf("Hello, World!");
}
Expand Down

0 comments on commit 45a6c2f

Please sign in to comment.