aboutsummaryrefslogtreecommitdiff
path: root/libs/cmake_common/mo2.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cmake_common/mo2.cmake')
-rw-r--r--libs/cmake_common/mo2.cmake48
1 files changed, 48 insertions, 0 deletions
diff --git a/libs/cmake_common/mo2.cmake b/libs/cmake_common/mo2.cmake
new file mode 100644
index 0000000..7e8c3f7
--- /dev/null
+++ b/libs/cmake_common/mo2.cmake
@@ -0,0 +1,48 @@
+cmake_minimum_required(VERSION 3.22)
+
+if (DEFINED MO2_DEFINED)
+ return()
+endif()
+
+option(MO2_INSTALL_IS_BIN
+ "if set, CMAKE_INSTALL_PREFIX is assumed to point to bin rather than one level below")
+
+if (MO2_INSTALL_IS_BIN)
+ set(MO2_INSTALL_BIN ".")
+else()
+ set(MO2_INSTALL_BIN "bin")
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/mo2_utils.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/mo2_versions.cmake)
+
+# this makes VS install everything when building solution
+if(MSVC)
+ set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
+endif()
+
+# this find Python globally rather than virtual environments, even when one is active
+set(Python_FIND_VIRTUALENV STANDARD)
+
+# this set the imported location of targets for missing configurations - this silents
+# many CMP0111 warnings from CMake
+set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel RelWithDebInfo Release None)
+set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel None)
+set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel None)
+
+# allow setting folder property on targets for better organization in VS
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+# put code generated by Qt in a autogen group in VS
+set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP autogen)
+set_property(GLOBAL PROPERTY AUTOMOC_SOURCE_GROUP autogen)
+set_property(GLOBAL PROPERTY AUTORCC_SOURCE_GROUP autogen)
+
+# put targets generated by Qt into a autogen folder (this is not the same as the above)
+set(QT_TARGETS_FOLDER autogen)
+
+include(${CMAKE_CURRENT_LIST_DIR}/mo2_cpp.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/mo2_python.cmake)
+
+# mark as included
+set(MO2_DEFINED true)