]> git.zndr.dk Git - codility.git/commitdiff
Add cmake folder master
authorJannik ZANDER <jzander@grundfos.com>
Fri, 10 Feb 2017 19:34:16 +0000 (20:34 +0100)
committerJannik ZANDER <jzander@grundfos.com>
Fri, 10 Feb 2017 19:34:16 +0000 (20:34 +0100)
AddUnitTest.cmake [deleted file]
CMakeLists.txt
CMakeLists.txt.in [deleted file]
cmake/AddUnitTest.cmake [new file with mode: 0644]
cmake/CMakeLists.txt.in [new file with mode: 0644]

diff --git a/AddUnitTest.cmake b/AddUnitTest.cmake
deleted file mode 100644 (file)
index 05f52ff..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-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 383368d533296486d4c36b31c71f8287a0259308..d26d427bd74d3f66b91c9f0e6cb1765e2fabdf69 100644 (file)
@@ -1,6 +1,6 @@
 cmake_minimum_required (VERSION 3.2)\r
 project(project_test)\r
-include(AddUnitTest.cmake)\r
+include(cmake/AddUnitTest.cmake)\r
 \r
 add_subdirectory( solution1 )\r
 add_subdirectory( solution2 )\r
diff --git a/CMakeLists.txt.in b/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/AddUnitTest.cmake b/cmake/AddUnitTest.cmake
new file mode 100644 (file)
index 0000000..722109e
--- /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("${CMAKE_CURRENT_SOURCE_DIR}/cmake/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
diff --git a/cmake/CMakeLists.txt.in b/cmake/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      ""
+)
+