CMakeLists.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #
  2. # Example CMakeLists.txt file to demonstrate how to make a designable Windows Forms project with CMake.
  3. #
  4. # Code modifications and example by John Farrier, john.farrier@helleboreconsulting.com
  5. #
  6. cmake_minimum_required(VERSION 2.8.10)
  7. # Project Name
  8. project(VSWindowsFormsResx CXX)
  9. include(CheckFunctionExists)
  10. include(CheckCXXSourceCompiles)
  11. include(CheckIncludeFile)
  12. # Note: The designable form is assumed to have a .h extension as is default in Visual Studio.
  13. # 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
  14. set(TARGET_H
  15. WindowsFormsResx/MyForm.h
  16. WindowsFormsResx/Header.h
  17. )
  18. set(TARGET_SRC
  19. WindowsFormsResx/MyForm.cpp
  20. WindowsFormsResx/Source.cpp
  21. )
  22. set_source_files_properties(${TARGET_SRC} PROPERTIES COMPILE_FLAGS "/clr")
  23. set(TARGET_RESX
  24. WindowsFormsResx/MyForm.resx
  25. )
  26. set(TARGET_LIBRARIES ${SYSLIBS})
  27. add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_H} ${TARGET_RESX})
  28. # Note: The property VS_GLOBAL_KEYWORD must be set.
  29. set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_KEYWORD "ManagedCProj")
  30. # Note: The property VS_DOTNET_REFERENCES must be set.
  31. set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES "System" "System.Data" "System.Drawing" "System.Windows.Forms" "System.Xml")
  32. # Note: Modification of compiler flags is required for CLR compatibility now that we are using .resx files.
  33. string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  34. string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")