aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMakeModules
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeModules')
-rw-r--r--CMakeModules/CreateDirectoryGroups.cmake15
-rw-r--r--CMakeModules/DetectArchitecture.cmake16
2 files changed, 31 insertions, 0 deletions
diff --git a/CMakeModules/CreateDirectoryGroups.cmake b/CMakeModules/CreateDirectoryGroups.cmake
new file mode 100644
index 00000000..e806421f
--- /dev/null
+++ b/CMakeModules/CreateDirectoryGroups.cmake
@@ -0,0 +1,15 @@
+# This function should be passed a list of all files in a target. It will automatically generate
+# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
+# one in the filesystem.
+function(create_directory_groups)
+ # Place any files that aren't in the source list in a separate group so that they don't get in
+ # the way.
+ source_group("Other Files" REGULAR_EXPRESSION ".")
+
+ foreach(file_name ${ARGV})
+ get_filename_component(dir_name "${file_name}" PATH)
+ # Group names use '\' as a separator even though the entire rest of CMake uses '/'...
+ string(REPLACE "/" "\\" group_name "${dir_name}")
+ source_group("${group_name}" FILES "${file_name}")
+ endforeach()
+endfunction()
diff --git a/CMakeModules/DetectArchitecture.cmake b/CMakeModules/DetectArchitecture.cmake
new file mode 100644
index 00000000..e984c6b8
--- /dev/null
+++ b/CMakeModules/DetectArchitecture.cmake
@@ -0,0 +1,16 @@
+include(CheckSymbolExists)
+function(detect_architecture symbol arch)
+ if (NOT DEFINED ARCHITECTURE)
+ set(CMAKE_REQUIRED_QUIET 1)
+ check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
+ unset(CMAKE_REQUIRED_QUIET)
+
+ # The output variable needs to be unique across invocations otherwise
+ # CMake's crazy scope rules will keep it defined
+ if (ARCHITECTURE_${arch})
+ set(ARCHITECTURE "${arch}" PARENT_SCOPE)
+ set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
+ add_definitions(-DARCHITECTURE_${arch}=1)
+ endif()
+ endif()
+endfunction()