File: CMakeLists.txt

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (51 lines) | stat: -rw-r--r-- 1,899 bytes parent folder | download | duplicates (5)
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
#
# Example CMakeLists.txt file to demonstrate how to make a designable Windows Forms project with CMake.
#
# Code modifications and example by John Farrier, john.farrier@helleboreconsulting.com
#

cmake_minimum_required(VERSION 3.10)

# Project Name
project(VSWindowsFormsResx CXX)

include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(CheckIncludeFile)

# Note: The designable form is assumed to have a .h extension as is default in Visual Studio.
# Note: The designable form is assumed to have a .resx file with the same name and path (save extension) as is default in Visual Studio

set(TARGET_H
  WindowsFormsResx/MyForm.h
  WindowsFormsResx/Header.h
  )

set(TARGET_SRC
  WindowsFormsResx/MyForm.cpp
  WindowsFormsResx/Source.cpp
  )
set_source_files_properties(${TARGET_SRC} PROPERTIES COMPILE_FLAGS "/clr")

set(TARGET_RESX
  WindowsFormsResx/MyForm.resx
  )

set(TARGET_LIBRARIES ${SYSLIBS})
add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_H} ${TARGET_RESX})
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 1[0-6]")
  # VS 17 2022 and above require a global mark on managed assemblies.
  # CMake adds this automatically when using COMMON_LANGUAGE_RUNTIME,
  # but this test covers direct use of /clr.
  set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_ManagedAssembly "true")
endif()

# Note: The property VS_GLOBAL_KEYWORD must be set.
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_KEYWORD "ManagedCProj")

# Note: The property VS_DOTNET_REFERENCES must be set.
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES "System" "System.Data" "System.Drawing" "System.Windows.Forms" "System.Xml")

# Note: Modification of compiler flags is required for CLR compatibility now that we are using .resx files.
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")