1
1
cmake_minimum_required (VERSION 3.15)
2
- project (Calculator CXX C )
2
+ project (Calculator)
3
3
4
4
#====================================================
5
5
# Enable policy
@@ -13,43 +13,40 @@ cmake_policy(SET CMP0091 NEW)
13
13
if (NOT CMAKE_BUILD_TYPE )
14
14
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type, one of: Release, Debug" FORCE)
15
15
endif ()
16
- message ("Build type for Calculator: ${CMAKE_BUILD_TYPE} " )
16
+ message ("Build type for ${PROJECT_NAME} : ${CMAKE_BUILD_TYPE} " )
17
+
18
+ #====================================================
19
+ # Set configuration types
20
+ #====================================================
21
+ if (NOT MSVC_IDE )
22
+ set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
23
+ else ()
24
+ #target_compile_options cannot set parameters for all configurations in MSVC
25
+ set (CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE} " CACHE STRING "" FORCE)
26
+ endif ()
27
+ message ("Configurations for IDE: ${CMAKE_CONFIGURATION_TYPES} " )
17
28
18
29
# check platform for build
19
30
set (IS_x64_PLATFORM FALSE CACHE BOOL "" FORCE)
20
31
if ("$ENV{PLATFORM} " MATCHES "x64" )
21
32
set (IS_x64_PLATFORM TRUE CACHE BOOL "" FORCE)
22
33
endif ()
23
34
24
- # Get plugin version from src/plugcalc/version.h and put it in PLUGIN_VERSION
25
- function (plugin_extract_version)
26
- file (READ "${CMAKE_CURRENT_LIST_DIR} /src/plugcalc/version.h" file_contents)
27
- string (REGEX MATCH "PLUGIN_VER_MAJOR ([0-9]+)" _ "${file_contents} " )
28
- if (NOT CMAKE_MATCH_COUNT EQUAL 1)
29
- message (FATAL_ERROR "Could not extract major version number from version.hpp" )
30
- endif ()
31
- set (ver_major ${CMAKE_MATCH_1} )
32
-
33
- string (REGEX MATCH "PLUGIN_VER_MINOR ([0-9]+)" _ "${file_contents} " )
34
- if (NOT CMAKE_MATCH_COUNT EQUAL 1)
35
- message (FATAL_ERROR "Could not extract minor version number from version.hpp" )
36
- endif ()
37
-
38
- set (ver_minor ${CMAKE_MATCH_1} )
39
- string (REGEX MATCH "PLUGIN_VER_PATCH ([0-9]+)" _ "${file_contents} " )
40
- if (NOT CMAKE_MATCH_COUNT EQUAL 1)
41
- message (FATAL_ERROR "Could not extract patch version number from version.hpp" )
42
- endif ()
43
- set (ver_patch ${CMAKE_MATCH_1} )
44
-
45
- set (PLUGIN_VERSION "${ver_major} .${ver_minor} .${ver_patch} " PARENT_SCOPE)
46
- endfunction ()
35
+ include (cmake/utils.cmake)
36
+ plugin_extract_version(${CMAKE_CURRENT_LIST_DIR} /src/plugcalc/version .h)
37
+ if (IS_x64_PLATFORM)
38
+ set (PACKAGE_FILE_NAME "${PROJECT_NAME} .${PLUGIN_VERSION} .x64" )
39
+ else ()
40
+ set (PACKAGE_FILE_NAME "${PROJECT_NAME} .${PLUGIN_VERSION} .x86" )
41
+ endif ()
47
42
48
- plugin_extract_version()
43
+ #====================================================
44
+ # build plugin
45
+ #====================================================
49
46
add_subdirectory (src)
50
47
51
48
#====================================================
52
- # build misc files
49
+ # build resource files
53
50
#====================================================
54
51
# used @@ESCAPE and ESCAPE@@ for escape @ in files
55
52
configure_file (res/file_id.diz.in res/file_id.diz)
@@ -59,11 +56,24 @@ configure_file(res/calcr.hlf.in res/calcr.hlf)
59
56
#====================================================
60
57
# install
61
58
#====================================================
59
+ install (TARGETS Calculator RUNTIME DESTINATION .)
62
60
install (DIRECTORY res/
63
61
DESTINATION .
64
62
PATTERN "*.in" EXCLUDE )
65
- install (FILES whatsnew_en.txt whatsnew_ru.txt
63
+ install (FILES
64
+ ${CMAKE_CURRENT_BINARY_DIR} /src/calc.map
66
65
${CMAKE_CURRENT_BINARY_DIR} /res/file_id.diz
67
66
${CMAKE_CURRENT_BINARY_DIR} /res/calce.hlf
68
67
${CMAKE_CURRENT_BINARY_DIR} /res/calcr.hlf
69
- DESTINATION .)
68
+ whatsnew_en.txt
69
+ whatsnew_ru.txt
70
+ DESTINATION .)
71
+
72
+ #====================================================
73
+ # cpack
74
+ #====================================================
75
+ set (CPACK_GENERATOR "ZIP" CACHE STRING "Generators to support. semi-colon delimited list" )
76
+ set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
77
+ set (CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME} " )
78
+
79
+ include (CPack)
0 commit comments