[aseprite] 121/196: Make building tests optional

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:50:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 7964f1feb14978ce42d0e70b877aef5eeb3bd4ea
Author: Azamat H. Hackimov <azamat.hackimov at gmail.com>
Date:   Tue Mar 29 15:06:59 2016 +0500

    Make building tests optional
    
    Added new option ENABLE_TESTS in CMake (ON by default)
---
 CMakeLists.txt         |  1 +
 cmake/Find-tests.cmake | 41 ++++++++++++++++++++++++++++++++++++
 src/CMakeLists.txt     | 57 +++++++++++++-------------------------------------
 3 files changed, 56 insertions(+), 43 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8a685b..f94d333 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,7 @@ option(USE_SKIA_BACKEND   "Use Skia backend" off)
 option(ENABLE_MEMLEAK     "Enable memory-leaks detector (only for developers)" off)
 option(ENABLE_UPDATER     "Enable automatic check for updates" on)
 option(ENABLE_WEBSERVER   "Enable support to run a webserver (for HTML5 gamedev)" off)
+option(ENABLE_TESTS       "Enable the unit tests" on)
 option(ENABLE_TRIAL_MODE  "Compile the trial version" off)
 option(ENABLE_STEAM       "Compile with Steam library" off)
 option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
diff --git a/cmake/Find-tests.cmake b/cmake/Find-tests.cmake
new file mode 100644
index 0000000..06a5ce7
--- /dev/null
+++ b/cmake/Find-tests.cmake
@@ -0,0 +1,41 @@
+# - Find tests
+# Find tests and run them
+#
+#  find_test(dir dependencies)
+#  DXGUID_FOUND       - True if dxguid found.
+
+
+function(find_tests dir dependencies)
+  file(GLOB tests ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*_tests.cpp)
+  list(REMOVE_AT ARGV 0)
+  
+  # Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
+  include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
+  
+  # See if the test is linked with "she" library.
+  list(FIND dependencies she link_with_she)
+  if(link_with_she)
+    set(extra_definitions -DLINKED_WITH_SHE)
+  endif()
+  
+  foreach(testsourcefile ${tests})
+    get_filename_component(testname ${testsourcefile} NAME_WE)
+    
+    add_executable(${testname} ${testsourcefile})
+    add_test(NAME ${testname} COMMAND ${testname})
+    
+    if(MSVC)
+      # Fix problem compiling gen from a Visual Studio solution
+      set_target_properties(${testname}
+      PROPERTIES LINK_FLAGS -ENTRY:"mainCRTStartup")
+    endif()
+    
+    target_link_libraries(${testname} gtest ${ARGV} ${PLATFORM_LIBS})
+    
+    if(extra_definitions)
+      set_target_properties(${testname}
+      PROPERTIES COMPILE_FLAGS ${extra_definitions})
+    endif()
+  endforeach()
+endfunction()
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b3647ea..763e36e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -165,47 +165,18 @@ install(DIRECTORY ../data
 ######################################################################
 # Tests
 
-function(find_tests dir dependencies)
-  file(GLOB tests ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*_tests.cpp)
-  list(REMOVE_AT ARGV 0)
-
-  # Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
-  include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
-
-  # See if the test is linked with "she" library.
-  list(FIND dependencies she link_with_she)
-  if(link_with_she)
-    set(extra_definitions -DLINKED_WITH_SHE)
-  endif()
+if(ENABLE_TESTS)
+  include(Find-tests)
+
+  find_tests(base base-lib)
+  find_tests(undo undo-lib)
+  find_tests(gfx gfx-lib)
+  find_tests(doc doc-lib)
+  find_tests(render render-lib)
+  find_tests(css css-lib)
+  find_tests(ui ui-lib)
+  find_tests(app/file app-lib)
+  find_tests(app app-lib)
+  find_tests(. app-lib)
+endif()
 
-  foreach(testsourcefile ${tests})
-    get_filename_component(testname ${testsourcefile} NAME_WE)
-
-    add_executable(${testname} ${testsourcefile})
-    add_test(NAME ${testname} COMMAND ${testname})
-
-    if(MSVC)
-      # Fix problem compiling gen from a Visual Studio solution
-      set_target_properties(${testname}
-	PROPERTIES LINK_FLAGS -ENTRY:"mainCRTStartup")
-    endif()
-
-    target_link_libraries(${testname} gtest ${ARGV} ${PLATFORM_LIBS})
-
-    if(extra_definitions)
-      set_target_properties(${testname}
-	PROPERTIES COMPILE_FLAGS ${extra_definitions})
-    endif()
-  endforeach()
-endfunction()
-
-find_tests(base base-lib)
-find_tests(undo undo-lib)
-find_tests(gfx gfx-lib)
-find_tests(doc doc-lib)
-find_tests(render render-lib)
-find_tests(css css-lib)
-find_tests(ui ui-lib)
-find_tests(app/file app-lib)
-find_tests(app app-lib)
-find_tests(. app-lib)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list