diff --git a/CMakeLists.txt b/CMakeLists.txt index c06d5fa..245c158 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,6 @@ add_executable(${PROJECT_NAME} WIN32 viewlog.c res/openvpn-gui-res.rc) -configure_file(config-msvc.h config.h COPYONLY) - find_package(OpenSSL REQUIRED) target_link_libraries(${PROJECT_NAME} OpenSSL::SSL Wtsapi32.lib @@ -48,6 +46,17 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") set(CMAKE_RC_FLAGS "/D \"HAVE_CONFIG_H\" /D \"_MSC_VER\"") +function(get_version_from_configure regex_arg ret) + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" VERSION_STR REGEX ${regex_arg}) + string(REGEX MATCH ${regex_arg} VERSION_STR "${VERSION_STR}") + set("${ret}" ${CMAKE_MATCH_1} PARENT_SCOPE) +endfunction() + +get_version_from_configure("_GUI_VERSION_MAJOR\\], \\[([0-9]+)\\]" GUI_VERSION_MAJOR) +get_version_from_configure("_GUI_VERSION_MINOR\\], \\[([0-9]+)\\]" GUI_VERSION_MINOR) + +configure_file(config-msvc.h.in config.h) + target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE diff --git a/config-msvc.h b/config-msvc.h.in similarity index 82% rename from config-msvc.h rename to config-msvc.h.in index 75ac8e5..b7d0bd5 100644 --- a/config-msvc.h +++ b/config-msvc.h.in @@ -22,7 +22,7 @@ #define PACKAGE_VERSION "11" /* Version in windows resource format */ -#define PACKAGE_VERSION_RESOURCE 11,14,0,0 +#define PACKAGE_VERSION_RESOURCE @GUI_VERSION_MAJOR@,@GUI_VERSION_MINOR@,0,0 /* Version as a string */ -#define PACKAGE_VERSION_RESOURCE_STR "11.14.0.0" +#define PACKAGE_VERSION_RESOURCE_STR "@GUI_VERSION_MAJOR@.@GUI_VERSION_MINOR@.0.0"