about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2020-04-06 14:27:51 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-11-04 15:14:47 +0000
commit7fbef46d4036390c8ed10943bc610916292ef67d (patch)
treed4eefb915e2dfd4ddff663f8bd3ff9bb0c188780
parentbef9f39d033ea5c9600f39af7cfd213e01aab4c1 (diff)
downloadklee-7fbef46d4036390c8ed10943bc610916292ef67d.tar.gz
[cmake] Switch to "newer" cmake version 3.5.0
Ubuntu 16.04 supports cmake 3.5.0 as default.
Cmake 2.8.12 was the default in 14.04.

Use cmake 3 to simplify cmake files.
-rw-r--r--CMakeLists.txt36
-rw-r--r--cmake/klee_add_component.cmake13
2 files changed, 9 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fa4fcc6..9fc54484 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,19 +10,9 @@
 ###############################################################################
 # Minimum CMake version and policies
 ###############################################################################
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.5.0)
 if (POLICY CMP0054)
-  # FIXME: This is horrible. With the old behaviour,
-  # quoted strings like "MSVC" in if() conditionals
-  # get implicitly dereferenced. The NEW behaviour
-  # doesn't do this but CMP0054 was only introduced
-  # in CMake 3.1 and we support lower versions as the
-  # minimum. We could set NEW here but it would be very
-  # confusing to use NEW for some builds and OLD for others
-  # which could lead to some subtle bugs. Instead when the
-  # minimum version is 3.1 change this policy to NEW and remove
-  # the hacks in place to work around it.
-  cmake_policy(SET CMP0054 OLD)
+  cmake_policy(SET CMP0054 NEW)
 endif()
 
 if (POLICY CMP0042)
@@ -63,19 +53,9 @@ set(PACKAGE_URL "\"https://klee.github.io\"")
 ################################################################################
 # Set various useful variables depending on CMake version
 ################################################################################
-if (("${CMAKE_VERSION}" VERSION_EQUAL "3.2") OR ("${CMAKE_VERSION}" VERSION_GREATER "3.2"))
-  # In CMake >= 3.2 add_custom_command() supports a ``USES_TERMINAL`` argument
-  set(ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG "USES_TERMINAL")
-else()
-  set(ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG "")
-endif()
+set(ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG "USES_TERMINAL")
 
-if (("${CMAKE_VERSION}" VERSION_EQUAL "3.4") OR ("${CMAKE_VERSION}" VERSION_GREATER "3.4"))
-  # In CMake >= 3.4 ExternalProject_Add_Step() supports a `USES_TERMINAL` argument
-  set(EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG "USES_TERMINAL" "1")
-else()
-  set(EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG "")
-endif()
+set(EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG "USES_TERMINAL" "1")
 
 ################################################################################
 # Sanity check - Disallow building in source.
@@ -302,12 +282,8 @@ endif()
 ################################################################################
 # C++ version
 ################################################################################
-if ("${CMAKE_VERSION}" VERSION_LESS "3.1")
-  add_global_cxx_flag("-std=c++14" REQUIRED)
-else ()
-  set(CMAKE_CXX_STANDARD 14)
-  set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif ()
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 ################################################################################
 # Warnings
diff --git a/cmake/klee_add_component.cmake b/cmake/klee_add_component.cmake
index ea1b30b2..4f9770ac 100644
--- a/cmake/klee_add_component.cmake
+++ b/cmake/klee_add_component.cmake
@@ -11,16 +11,9 @@ function(klee_add_component target_name)
   # Components are explicitly STATIC because we don't support building them
   # as shared libraries.
   add_library(${target_name} STATIC ${ARGN})
-  # Use of `PUBLIC` means these will propagate to targets that use this component.
-  if (("${CMAKE_VERSION}" VERSION_EQUAL "3.3") OR ("${CMAKE_VERSION}" VERSION_GREATER "3.3"))
-    # In newer CMakes we can make sure that the flags are only used when compiling C++
-    target_compile_options(${target_name} PUBLIC
-      $<$<COMPILE_LANGUAGE:CXX>:${KLEE_COMPONENT_CXX_FLAGS}>)
-  else()
-    # For older CMakes just live with the warnings we get for passing C++ only flags
-    # to the C compiler.
-    target_compile_options(${target_name} PUBLIC ${KLEE_COMPONENT_CXX_FLAGS})
-  endif()
+  # In newer CMakes we can make sure that the flags are only used when compiling C++
+  target_compile_options(${target_name} PUBLIC
+    $<$<COMPILE_LANGUAGE:CXX>:${KLEE_COMPONENT_CXX_FLAGS}>)
   target_include_directories(${target_name} PUBLIC ${KLEE_COMPONENT_EXTRA_INCLUDE_DIRS})
   target_compile_definitions(${target_name} PUBLIC ${KLEE_COMPONENT_CXX_DEFINES})
   target_link_libraries(${target_name} PUBLIC ${KLEE_COMPONENT_EXTRA_LIBRARIES})