summaryrefslogtreecommitdiff
path: root/win/upgrade_wizard/CMakeLists.txt
blob: f4148ee98d209c179aa66d18be610721f05ddaf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
IF(NOT MSVC)
  RETURN()
ENDIF()
IF(CMAKE_C_COMPILER_ID MATCHES Clang)
  # MFC stuff does not compile with clang
  RETURN()
ENDIF()
IF(CMAKE_USING_VC_FREE_TOOLS)
  # No MFC, so it cannot be built
  RETURN()
ENDIF()

# We need MFC
# /permissive- flag does not play well with MFC, disable it.
STRING(REPLACE "/permissive-"  "" CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}")

FIND_PACKAGE(MFC)
IF(NOT MFC_FOUND)
  IF(BUILD_RELEASE)
    MESSAGE(FATAL_ERROR
    "Can't find MFC. It is necessary for producing official package"
  )
  ENDIF()
  RETURN()
ENDIF()
IF(MSVC_CRT_TYPE MATCHES "/MD")
  # MFC should be dynamically linked
  SET(CMAKE_MFC_FLAG 2)
ELSE()
  # MFC should be statically linked
  SET(CMAKE_MFC_FLAG 1)
ENDIF()
# Enable exception handling (avoids warnings)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNO_WARN_MBCS_MFC_DEPRECATION")

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
MYSQL_ADD_EXECUTABLE(mysql_upgrade_wizard
  upgrade.cpp upgradeDlg.cpp upgrade.rc
  COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade_wizard winservice)
# upgrade_wizard is Windows executable, set WIN32_EXECUTABLE so it does not
# create a console.
SET_TARGET_PROPERTIES(mysql_upgrade_wizard PROPERTIES WIN32_EXECUTABLE 1)

# Embed Vista "admin" manifest, since upgrade_wizard needs admin privileges
# to change service configuration. Due to a CMake bug http://www.vtk.org/Bug/view.php?id=11171
# it is not possible currenly to do it with linker flags. Work around is to use
# manifest tool mt.exe and embed the manifest post-build.
ADD_CUSTOM_COMMAND(
  TARGET mysql_upgrade_wizard POST_BUILD
  COMMAND mt.exe -manifest ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_wizard.exe.manifest
  "-outputresource:$<TARGET_FILE:mysql_upgrade_wizard>;#1"
)