]> git.zndr.dk Git - codility.git/commitdiff
Remove FindXXX
authorJannik ZANDER <jzander@grundfos.com>
Fri, 10 Feb 2017 18:25:09 +0000 (19:25 +0100)
committerJannik ZANDER <jzander@grundfos.com>
Fri, 10 Feb 2017 18:26:45 +0000 (19:26 +0100)
AddUnitTest.cmake [new file with mode: 0644]
CMakeLists.txt
CMakeLists.txt.in [new file with mode: 0644]
cmake/CMakeLists.txt.in [deleted file]
cmake/FindAddUnitTest.cmake [deleted file]
cmake/Findcppunit.cmake [deleted file]
cmake/gtest.cmake [deleted file]

diff --git a/AddUnitTest.cmake b/AddUnitTest.cmake
new file mode 100644 (file)
index 0000000..05f52ff
--- /dev/null
@@ -0,0 +1,124 @@
+cmake_minimum_required (VERSION 3.2)\r
+\r
+enable_testing()\r
+set_property( GLOBAL PROPERTY USE_FOLDERS ON)\r
+\r
+function(add_unit)\r
+  cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN})\r
+  print_target("Component" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}")\r
+  if ("${my_SRCS}" MATCHES ".*\\.(cpp|c)")\r
+    # Add public library\r
+    add_library(${my_TARGET} "${my_SRCS}")\r
+    foreach(inc ${my_INCS})\r
+      target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
+    endforeach()\r
+    target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}")\r
+    target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS})\r
+    add_unitfolder(${my_TARGET} "${my_SRCS}")\r
+  else()\r
+    # Add interface library\r
+    add_library(${my_TARGET} INTERFACE)\r
+    foreach(inc ${my_INCS})\r
+      target_include_directories(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
+    endforeach()\r
+    target_link_libraries(${my_TARGET} INTERFACE "${my_DEPS}")\r
+    target_compile_definitions(${my_TARGET} INTERFACE ${my_DEFS})\r
+\r
+    # Add header files to IDE view (this has no effect on build)\r
+    foreach(src ${my_SRCS})\r
+      target_sources(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${src}")\r
+    endforeach()\r
+  endif() \r
+endfunction()\r
+\r
+function(add_unittest)\r
+  cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN})\r
+  print_target("UnitTest" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}")\r
+\r
+  # Add test executable\r
+  add_executable(${my_TARGET} "${my_SRCS}")\r
+  foreach(inc ${my_INCS})\r
+    target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
+  endforeach()\r
+  target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" gtest gtest_main)\r
+\r
+  # Add test to test suite\r
+  add_test(${my_TARGET} ${my_TARGET})\r
+  add_unitfolder(${my_TARGET} "${my_SRCS}")\r
+\r
+  # Run test after build\r
+  add_custom_command(TARGET ${my_TARGET} POST_BUILD COMMAND ${my_TARGET})\r
+endfunction()\r
+\r
+function(add_unitfolder mytarget mysrcs)\r
+  # source_group("" FILES "${mysrcs}")\r
+  string(REGEX REPLACE "_stub*$" "" myfolder ${mytarget})\r
+  string(REGEX REPLACE "_stubs*$" "" myfolder ${mytarget})\r
+  string(REGEX REPLACE "_test*$" "" myfolder ${myfolder})\r
+  string(REGEX REPLACE "_if*$"   "" myfolder ${myfolder})\r
+  string(TOUPPER ${myfolder} myfolder)\r
+  set_property(TARGET ${mytarget} PROPERTY FOLDER "${myfolder}")\r
+endfunction()\r
+\r
+# Print target function \r
+function(print_target type target srcs incs deps defs)\r
+  message("${type}:")\r
+  message("  ${target}:")\r
+  message("    Sources:")\r
+  foreach(src ${srcs})\r
+  message("      - ${src}")\r
+  endforeach()\r
+  message("    Includes:")\r
+  foreach(inc ${incs})\r
+  message("      - ${inc}")\r
+  endforeach()\r
+  message("    Dependencies:")\r
+  foreach(dep ${deps})\r
+  message("      - ${dep}")\r
+  endforeach()\r
+  message("    Definitions:")\r
+  foreach(def ${defs})\r
+  message("      - ${def}")\r
+  endforeach()\r
+  message("===================================================")\r
+endfunction()\r
+\r
+# Compiler options \r
+if(MSVC)\r
+  add_definitions(/FC /D_CRT_SECURE_NO_WARNINGS)\r
+endif()\r
+\r
+if(CMAKE_COMPILER_IS_GNUCXX)\r
+  add_definitions(-Wall -Wno-deprecated -pthread -D__PC__)\r
+endif()\r
+\r
+# Download and unpack googletest at configure time\r
+configure_file("CMakeLists.txt.in" googletest-download/CMakeLists.txt)\r
+execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .\r
+  RESULT_VARIABLE result\r
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )\r
+if(result)\r
+  message(FATAL_ERROR "CMake step for googletest failed: ${result}")\r
+endif()\r
+execute_process(COMMAND ${CMAKE_COMMAND} --build .\r
+  RESULT_VARIABLE result\r
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )\r
+if(result)\r
+  message(FATAL_ERROR "Build step for googletest failed: ${result}")\r
+endif()\r
+\r
+# Prevent overriding the parent project's compiler/linker\r
+# settings on Windows\r
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)\r
+\r
+# Add googletest directly to our build. This defines\r
+# the gtest and gtest_main targets.\r
+add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src\r
+                 ${CMAKE_BINARY_DIR}/googletest-build)\r
+\r
+# The gtest/gtest_main targets carry header search path\r
+# dependencies automatically when using CMake 2.8.11 or\r
+# later. Otherwise we have to add them here ourselves.\r
+if (CMAKE_VERSION VERSION_LESS 2.8.11)\r
+  include_directories("${gtest_SOURCE_DIR}/include")\r
+endif()\r
index 5f67c8b7aa2158a2a56ebe17d53230f8db2a0c45..383368d533296486d4c36b31c71f8287a0259308 100644 (file)
@@ -1,10 +1,6 @@
 cmake_minimum_required (VERSION 3.2)\r
 project(project_test)\r
-\r
-set(USE_GTEST "yes")\r
-\r
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")\r
-find_package(AddUnitTest)\r
+include(AddUnitTest.cmake)\r
 \r
 add_subdirectory( solution1 )\r
 add_subdirectory( solution2 )\r
diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in
new file mode 100644 (file)
index 0000000..73ea4a6
--- /dev/null
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.2) 
+
+project(googletest-download NONE)
+
+include(ExternalProject)
+ExternalProject_Add(googletest
+  GIT_REPOSITORY    https://github.com/google/googletest.git
+  GIT_TAG           master
+  SOURCE_DIR        "${CMAKE_BINARY_DIR}/googletest-src"
+  BINARY_DIR        "${CMAKE_BINARY_DIR}/googletest-build"
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND     ""
+  INSTALL_COMMAND   ""
+  TEST_COMMAND      ""
+)
+
diff --git a/cmake/CMakeLists.txt.in b/cmake/CMakeLists.txt.in
deleted file mode 100644 (file)
index 73ea4a6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-cmake_minimum_required(VERSION 3.2) 
-
-project(googletest-download NONE)
-
-include(ExternalProject)
-ExternalProject_Add(googletest
-  GIT_REPOSITORY    https://github.com/google/googletest.git
-  GIT_TAG           master
-  SOURCE_DIR        "${CMAKE_BINARY_DIR}/googletest-src"
-  BINARY_DIR        "${CMAKE_BINARY_DIR}/googletest-build"
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND     ""
-  INSTALL_COMMAND   ""
-  TEST_COMMAND      ""
-)
-
diff --git a/cmake/FindAddUnitTest.cmake b/cmake/FindAddUnitTest.cmake
deleted file mode 100644 (file)
index 0a69117..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-cmake_minimum_required (VERSION 3.2)\r
-\r
-enable_testing()\r
-set_property( GLOBAL PROPERTY USE_FOLDERS ON)\r
-\r
-################################\r
-# Add unit function \r
-################################\r
-function(add_unit)\r
-  cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN})\r
-  print_target("Component" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}")\r
-  if ("${my_SRCS}" MATCHES ".*\\.(cpp|c)")\r
-    # Add public library\r
-    add_library(${my_TARGET} "${my_SRCS}")\r
-    foreach(inc ${my_INCS})\r
-      target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
-    endforeach()\r
-    target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}")\r
-    target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS})\r
-    add_unitfolder(${my_TARGET} "${my_SRCS}")\r
-  else()\r
-    # Add interface library\r
-    add_library(${my_TARGET} INTERFACE)\r
-    foreach(inc ${my_INCS})\r
-      target_include_directories(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
-    endforeach()\r
-    target_link_libraries(${my_TARGET} INTERFACE "${my_DEPS}")\r
-    target_compile_definitions(${my_TARGET} INTERFACE ${my_DEFS})\r
-\r
-    # Add header files to IDE view (this has no effect on build)\r
-    foreach(src ${my_SRCS})\r
-      target_sources(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${src}")\r
-    endforeach()\r
-  endif() \r
-endfunction()\r
-\r
-################################\r
-# Add unittest function \r
-################################\r
-function(add_unittest)\r
-  cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN})\r
-  print_target("UnitTest" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}")\r
-\r
-  # Add test executable\r
-  add_executable(${my_TARGET} "${my_SRCS}")\r
-  foreach(inc ${my_INCS})\r
-    target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}")\r
-  endforeach()\r
-  if (USE_GTEST)\r
-    if(GTEST_FOUND)\r
-      target_include_directories(${my_TARGET} PUBLIC "${GTEST_INCLUDE_DIRS}")\r
-      target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" ${GTEST_BOTH_LIBRARIES})\r
-    else()\r
-      target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" gtest gtest_main)\r
-    endif()\r
-    target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS} USE_GTEST)\r
-  else()\r
-    target_include_directories(${my_TARGET} PUBLIC "${CPPUNIT_INCLUDE_DIRS}")\r
-    target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" ${CPPUNIT_LIBRARIES})\r
-    target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS})\r
-  endif()\r
-  # Add test to test suite\r
-  add_test(${my_TARGET} ${my_TARGET})\r
-  add_unitfolder(${my_TARGET} "${my_SRCS}")\r
-  # Run test after build\r
-  add_custom_command(TARGET ${my_TARGET} POST_BUILD COMMAND ${my_TARGET})\r
-endfunction()\r
-\r
-################################\r
-# Add add_unitfolder function (only for IDE)\r
-################################\r
-function(add_unitfolder mytarget mysrcs)\r
-  # source_group("" FILES "${mysrcs}")\r
-  string(REGEX REPLACE "_stub*$" "" myfolder ${mytarget})\r
-  string(REGEX REPLACE "_stubs*$" "" myfolder ${mytarget})\r
-  string(REGEX REPLACE "_test*$" "" myfolder ${myfolder})\r
-  string(REGEX REPLACE "_if*$"   "" myfolder ${myfolder})\r
-  string(TOUPPER ${myfolder} myfolder)\r
-  set_property(TARGET ${mytarget} PROPERTY FOLDER "${myfolder}")\r
-endfunction()\r
-\r
-################################\r
-# Print target function \r
-################################\r
-function(print_target type target srcs incs deps defs)\r
-  message("${type}:")\r
-  message("  ${target}:")\r
-  message("    Sources:")\r
-  foreach(src ${srcs})\r
-  message("      - ${src}")\r
-  endforeach()\r
-  message("    Includes:")\r
-  foreach(inc ${incs})\r
-  message("      - ${inc}")\r
-  endforeach()\r
-  message("    Dependencies:")\r
-  foreach(dep ${deps})\r
-  message("      - ${dep}")\r
-  endforeach()\r
-  message("    Definitions:")\r
-  foreach(def ${defs})\r
-  message("      - ${def}")\r
-  endforeach()\r
-  message("===================================================")\r
-endfunction()\r
-\r
-\r
-################################\r
-# Compiler options \r
-################################\r
-if(MSVC)\r
-  add_definitions(/FC /D_CRT_SECURE_NO_WARNINGS)\r
-endif()\r
-\r
-if(CMAKE_COMPILER_IS_GNUCXX)\r
-  add_definitions(-Wall -Wno-deprecated -pthread -D__PC__)\r
-endif()\r
-\r
-################################\r
-# Configure testing framework \r
-################################\r
-\r
-if(USE_GTEST)\r
-  if(NOT GTEST_ROOT)\r
-    if(NOT $ENV{GTEST_DIR} STREQUAL "")\r
-      set(GTEST_ROOT "$ENV{GTEST_DIR}")\r
-    else()\r
-      set(GTEST_ROOT "C:/googletest-release-1.7.0")\r
-    endif()\r
-  endif()\r
-\r
-  find_package(gtest)\r
-  if(NOT GTEST_FOUND)\r
-    # Add external google test project\r
-    find_package(git REQUIRED)\r
-    include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/gtest.cmake")\r
-  endif()\r
-else()\r
-  if(NOT CPPUNIT_ROOT_DIR)\r
-    if(NOT $ENV{CPPUNITDIR} STREQUAL "")\r
-      set(CPPUNIT_ROOT_DIR "$ENV{CPPUNITDIR}/lib")\r
-    else()\r
-      set(CPPUNIT_ROOT_DIR "C:/cppunit-1.12.1/lib")\r
-    endif()\r
-  endif()\r
-\r
-  find_package(cppunit REQUIRED)\r
-endif()\r
-\r
-message("===================================================")\r
diff --git a/cmake/Findcppunit.cmake b/cmake/Findcppunit.cmake
deleted file mode 100644 (file)
index b83b67e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# - try to find cppunit library
-#
-# Cache Variables: (probably not for direct use in your scripts)
-#  CPPUNIT_INCLUDE_DIR
-#  CPPUNIT_LIBRARY
-#
-# Non-cache variables you might use in your CMakeLists.txt:
-#  CPPUNIT_FOUND
-#  CPPUNIT_INCLUDE_DIRS
-#  CPPUNIT_LIBRARIES
-#
-# Requires these CMake modules:
-#  SelectLibraryConfigurations (included with CMake >= 2.8.0)
-#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
-#
-# Original Author:
-# 2009-2011 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
-# http://academic.cleardefinition.com
-# Iowa State University HCI Graduate Program/VRAC
-#
-# Copyright Iowa State University 2009-2011.
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-set(CPPUNIT_ROOT_DIR
-       "${CPPUNIT_ROOT_DIR}"
-       CACHE
-       PATH
-       "Directory to search")
-
-find_library(CPPUNIT_LIBRARY_RELEASE
-       NAMES
-       cppunit
-       HINTS
-       "${CPPUNIT_ROOT_DIR}")
-
-find_library(CPPUNIT_LIBRARY_DEBUG
-       NAMES
-       cppunitd
-       HINTS
-       "${CPPUNIT_ROOT_DIR}")
-
-include(SelectLibraryConfigurations)
-select_library_configurations(CPPUNIT)
-
-# Might want to look close to the library first for the includes.
-get_filename_component(_libdir "${CPPUNIT_LIBRARY_RELEASE}" PATH)
-
-find_path(CPPUNIT_INCLUDE_DIR
-       NAMES
-       cppunit/TestCase.h
-       HINTS
-       "${_libdir}/.."
-       PATHS
-       "${CPPUNIT_ROOT_DIR}"
-       PATH_SUFFIXES
-       include/)
-
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(cppunit
-       DEFAULT_MSG
-       CPPUNIT_LIBRARY
-       CPPUNIT_INCLUDE_DIR)
-
-if(CPPUNIT_FOUND)
-       set(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS})
-       set(CPPUNIT_INCLUDE_DIRS "${CPPUNIT_INCLUDE_DIR}")
-       mark_as_advanced(CPPUNIT_ROOT_DIR)
-endif()
-
-mark_as_advanced(CPPUNIT_INCLUDE_DIR
-       CPPUNIT_LIBRARY_RELEASE
-       CPPUNIT_LIBRARY_DEBUG)
-
diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake
deleted file mode 100644 (file)
index 5c92fde..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-cmake_minimum_required (VERSION 3.2)
-
-find_path (my_PATH NAMES CMakeLists.txt.in HINTS ${CMAKE_MODULE_PATH})
-
-# Download and unpack googletest at configure time
-configure_file("${my_PATH}/CMakeLists.txt.in" googletest-download/CMakeLists.txt)
-execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
-  RESULT_VARIABLE result
-  WORKING_DIRECTORY ${CMAKE_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_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_BINARY_DIR}/googletest-src
-                 ${CMAKE_BINARY_DIR}/googletest-build)
-
-# 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()