release 0.1.12
[liba.git] / cmake / Project.cmake
blobb3dc5b2b3d25030319c901bcbe39f94cd6f34705
1 set(PROJECT_VERSION 0.1.12)
2 set(PROJECT_LICENSE MPL-2.0)
3 set(PROJECT_CONTACT tqfx@tqfx.org)
4 set(PROJECT_DESCRIPTION "An algorithm library based on C/C++")
5 set(PROJECT_HOMEPAGE_URL "https://github.com/tqfx/liba")
6 string(REGEX MATCH "[^.]+\\.[^.]+\\.[0-9]+" PROJECT_VERSION_PATCH "${PROJECT_VERSION}")
7 string(REGEX REPLACE "^[^.]+\\.[^.]+\\.([0-9]+).*" "\\1" PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
8 string(REGEX MATCH "[^.]+\\.[0-9]+" PROJECT_VERSION_MINOR "${PROJECT_VERSION}")
9 string(REGEX REPLACE "^[^.]+\\.([0-9]+).*" "\\1" PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
10 string(REGEX MATCH "[0-9]+" PROJECT_VERSION_MAJOR "${PROJECT_VERSION}")
11 if(PROJECT_NAME)
12   set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION})
13   set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
14   set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
15   set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH})
16 endif()
17 if(PROJECT_NAME)
18   set(${PROJECT_NAME}_DESCRIPTION ${PROJECT_DESCRIPTION})
19 endif()
20 if(PROJECT_NAME)
21   set(${PROJECT_NAME}_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL})
22 endif()
23 if(PROJECT_NAME)
24   set(${PROJECT_NAME}_LICENSE ${PROJECT_LICENSE})
25 endif()
26 if(CMAKE_VERSION VERSION_LESS 3.21)
27   if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
28     set(PROJECT_IS_TOP_LEVEL 1)
29   else()
30     set(PROJECT_IS_TOP_LEVEL 0)
31   endif()
32 endif()
33 if(CMAKE_C_COMPILER_ID MATCHES "TinyCC")
34   string(FIND CMAKE_C_FLAGS "-std=c${CMAKE_C_STANDARD}" index)
35   if(${index} EQUAL -1)
36     string(STRIP "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}" CMAKE_C_FLAGS)
37   endif()
38 endif()
39 if(CMAKE_VERSION VERSION_LESS 3.1 AND CMAKE_C_COMPILER_ID MATCHES "GNU|[Cc]lang|LLVM")
40   string(FIND CMAKE_C_FLAGS "-std=c${CMAKE_C_STANDARD}" index)
41   if(${index} EQUAL -1)
42     string(STRIP "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}" CMAKE_C_FLAGS)
43   endif()
44 endif()
45 if(CMAKE_VERSION VERSION_LESS 3.1 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|[Cc]lang|LLVM")
46   string(FIND CMAKE_CXX_FLAGS "-std=c++${CMAKE_CXX_STANDARD}" index)
47   if(${index} EQUAL -1)
48     string(STRIP "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}" CMAKE_CXX_FLAGS)
49   endif()
50 endif()
51 if(NOT CMAKE_PROJECT_VERSION_PATCH AND PROJECT_IS_TOP_LEVEL)
52   set(CMAKE_PROJECT_VERSION_PATCH ${PROJECT_VERSION_PATCH} CACHE STATIC "Value Computed by CMake" FORCE)
53 endif()
54 if(NOT CMAKE_PROJECT_VERSION_MINOR AND PROJECT_IS_TOP_LEVEL)
55   set(CMAKE_PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR} CACHE STATIC "Value Computed by CMake" FORCE)
56 endif()
57 if(NOT CMAKE_PROJECT_VERSION_MAJOR AND PROJECT_IS_TOP_LEVEL)
58   set(CMAKE_PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} CACHE STATIC "Value Computed by CMake" FORCE)
59 endif()
60 if(NOT CMAKE_PROJECT_HOMEPAGE_URL AND PROJECT_IS_TOP_LEVEL)
61   set(CMAKE_PROJECT_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL} CACHE STATIC "Value Computed by CMake" FORCE)
62 endif()
63 if(NOT CMAKE_PROJECT_DESCRIPTION AND PROJECT_IS_TOP_LEVEL)
64   set(CMAKE_PROJECT_DESCRIPTION ${PROJECT_DESCRIPTION} CACHE STATIC "Value Computed by CMake" FORCE)
65 endif()
66 if(NOT CMAKE_PROJECT_VERSION AND PROJECT_IS_TOP_LEVEL)
67   set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION} CACHE STATIC "Value Computed by CMake" FORCE)
68 endif()
69 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ${PROJECT_NAME})
70 set(CPACK_RPM_PACKAGE_LICENSE ${PROJECT_LICENSE})
71 set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
72 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
73 set(index)