Refactor Clang module. webgl
authorBryan Dunsmore <dunsmoreb@gmail.com>
Sat, 01 Dec 2012 15:52:36 -0600
branchwebgl
changeset 8113 0ad9c42dca7c
parent 8111 4307de8780fa
child 8116 d24257910f8d
Refactor Clang module.
CMakeLists.txt
cmake_modules/FindClang.cmake
--- a/CMakeLists.txt	Fri Nov 30 21:28:40 2012 -0600
+++ b/CMakeLists.txt	Sat Dec 01 15:52:36 2012 -0600
@@ -66,18 +66,17 @@
 set(CPACK_PACKAGE_VERSION_PATCH 19${version_suffix})
 set(HEDGEWARS_PROTO_VER 44)
 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
-SET(REQUIRED_CLANG_VERSION 3.0)
+set(required_clang_version 3.0)
 
 
 # Check LLVM/Clang version
-FIND_PACKAGE(Clang)
+find_package(Clang)
 
-IF (CLANG_VERSION VERSION_GREATER REQUIRED_CLANG_VERSION
-    OR CLANG_VERSION VERSION_EQUAL REQUIRED_CLANG_VERSION)
-    MESSAGE(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
-ELSE()
-    MESSAGE(FATAL_ERROR "Necessary LLVM/Clang version not found (version >= ${REQUIRED_CLANG_VERSION} required)")
-ENDIF()
+if (CLANG_VERSION VERSION_LESS required_clang_version)
+    message(FATAL_ERROR "Necessary LLVM/Clang version not found (version >= ${REQUIRED_CLANG_VERSION} required)")
+else()
+    message(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
+endif()
 
 
 #bundle .app setup
--- a/cmake_modules/FindClang.cmake	Fri Nov 30 21:28:40 2012 -0600
+++ b/cmake_modules/FindClang.cmake	Sat Dec 01 15:52:36 2012 -0600
@@ -1,20 +1,20 @@
 # Load LLVM/Clang
-IF (CLANG)
-    SET(CLANG_EXECUTABLE ${CLANG})
-ELSE()
-    FIND_PROGRAM(CLANG_EXECUTABLE
+if (CLANG)
+    set(CLANG_EXECUTABLE ${CLANG})
+else()
+    find_program(CLANG_EXECUTABLE
         NAMES clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang
         PATHS /opt/local/bin /usr/local/bin /usr/bin)
-ENDIF()
+endif()
 
 # Check LLVM/Clang version
-IF (CLANG_EXECUTABLE)
-    EXEC_PROGRAM(${CLANG_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE CLANG_VERSION_FULL)
+if (CLANG_EXECUTABLE)
+    exec_program(${CLANG_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE CLANG_VERSION_FULL)
 
-    STRING(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION_LONG "${CLANG_VERSION_FULL}")
-    STRING(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION_LONG}")
-ELSE()
-    MESSAGE(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
-ENDIF()
+    string(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION_LONG "${CLANG_VERSION_FULL}")
+    string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION_LONG}")
+else()
+    message(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
+endif()
 
-SET(CMAKE_C_COMPILER ${CLANG_EXECUTABLE})
+set(CMAKE_C_COMPILER ${CLANG_EXECUTABLE})