release 0.1.15
[liba.git] / cmake / Project.cmake
blobefb28e6c3cfc82e7d99897f9fe9e6a1dcf110c16
1 set(PROJECT_VERSION 0.1.15)
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 MATCHALL "[0-9]+" VERSION "${PROJECT_VERSION}")
7 list(GET VERSION 0 PROJECT_VERSION_MAJOR)
8 list(GET VERSION 1 PROJECT_VERSION_MINOR)
9 list(GET VERSION 2 PROJECT_VERSION_PATCH)
10 if(PROJECT_NAME)
11   set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION})
12   set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
13   set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
14   set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH})
15 endif()
16 if(PROJECT_NAME)
17   set(${PROJECT_NAME}_DESCRIPTION ${PROJECT_DESCRIPTION})
18 endif()
19 if(PROJECT_NAME)
20   set(${PROJECT_NAME}_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL})
21 endif()
22 if(PROJECT_NAME)
23   set(${PROJECT_NAME}_LICENSE ${PROJECT_LICENSE})
24 endif()
25 if(CMAKE_VERSION VERSION_LESS 3.21)
26   if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
27     set(PROJECT_IS_TOP_LEVEL 1)
28   else()
29     set(PROJECT_IS_TOP_LEVEL 0)
30   endif()
31 endif()
32 if(CMAKE_C_COMPILER_ID MATCHES "TinyCC")
33   string(FIND CMAKE_C_FLAGS "-std=c${CMAKE_C_STANDARD}" found)
34   if(${found} EQUAL -1)
35     string(STRIP "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}" CMAKE_C_FLAGS)
36   endif()
37 endif()
38 if(CMAKE_VERSION VERSION_LESS 3.1 AND CMAKE_C_COMPILER_ID MATCHES "GNU|[Cc]lang|LLVM")
39   string(FIND CMAKE_C_FLAGS "-std=c${CMAKE_C_STANDARD}" found)
40   if(${found} EQUAL -1)
41     string(STRIP "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}" CMAKE_C_FLAGS)
42   endif()
43 endif()
44 if(CMAKE_VERSION VERSION_LESS 3.1 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|[Cc]lang|LLVM")
45   string(FIND CMAKE_CXX_FLAGS "-std=c++${CMAKE_CXX_STANDARD}" found)
46   if(${found} EQUAL -1)
47     string(STRIP "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}" CMAKE_CXX_FLAGS)
48   endif()
49 endif()
50 if(NOT CMAKE_PROJECT_VERSION_PATCH AND PROJECT_IS_TOP_LEVEL)
51   set(CMAKE_PROJECT_VERSION_PATCH ${PROJECT_VERSION_PATCH} CACHE STATIC "Value Computed by CMake" FORCE)
52 endif()
53 if(NOT CMAKE_PROJECT_VERSION_MINOR AND PROJECT_IS_TOP_LEVEL)
54   set(CMAKE_PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR} CACHE STATIC "Value Computed by CMake" FORCE)
55 endif()
56 if(NOT CMAKE_PROJECT_VERSION_MAJOR AND PROJECT_IS_TOP_LEVEL)
57   set(CMAKE_PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} CACHE STATIC "Value Computed by CMake" FORCE)
58 endif()
59 if(NOT CMAKE_PROJECT_HOMEPAGE_URL AND PROJECT_IS_TOP_LEVEL)
60   set(CMAKE_PROJECT_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL} CACHE STATIC "Value Computed by CMake" FORCE)
61 endif()
62 if(NOT CMAKE_PROJECT_DESCRIPTION AND PROJECT_IS_TOP_LEVEL)
63   set(CMAKE_PROJECT_DESCRIPTION ${PROJECT_DESCRIPTION} CACHE STATIC "Value Computed by CMake" FORCE)
64 endif()
65 if(NOT CMAKE_PROJECT_VERSION AND PROJECT_IS_TOP_LEVEL)
66   set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION} CACHE STATIC "Value Computed by CMake" FORCE)
67 endif()
68 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ${PROJECT_NAME})
69 set(CPACK_RPM_PACKAGE_LICENSE ${PROJECT_LICENSE})
70 set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
71 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})