]> source.dussan.org Git - tigervnc.git/commitdiff
Prevent incorrect cmake usage
authorPierre Ossman <ossman@cendio.se>
Thu, 28 Dec 2023 08:39:08 +0000 (09:39 +0100)
committerPierre Ossman <ossman@cendio.se>
Thu, 28 Dec 2023 08:39:08 +0000 (09:39 +0100)
It's a reoccurring issue that users try to build individual components
by pointing cmake at a specific subdirectory, e.g. 'cmake vncviewer'.
CMake, unfortunately, has insufficient protection against this so we'll
need to add a manual check.

This commit only adds it to the most likely places for misuse so we
don't have to pollute every CMakeLists.txt.

tests/CMakeLists.txt
unix/CMakeLists.txt
vncviewer/CMakeLists.txt
win/CMakeLists.txt

index 4399dad0f049ffe8a698b40a77c66ae17ad1ee47..3d0d43903c25ff80ee623ab3afc81a5c7fd94477 100644 (file)
@@ -1,3 +1,7 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  message(FATAL_ERROR "cmake must be invoked with the top level directory")
+endif()
+
 # Benchmarking tools
 add_subdirectory(perf)
 
index 5456e00b2399a5249fc21adfd49ecb4d21daef15..a47260067a98179fd0c9409a438873d1581c3858 100644 (file)
@@ -1,3 +1,7 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  message(FATAL_ERROR "cmake must be invoked with the top level directory")
+endif()
+
 add_subdirectory(tx)
 add_subdirectory(common)
 add_subdirectory(vncconfig)
index 3191176b45abfa777268cefa04aaabe3012427a5..1f9c6d39f42b9d7c3812f5ce07af405fa979ea68 100644 (file)
@@ -1,3 +1,7 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  message(FATAL_ERROR "cmake must be invoked with the top level directory")
+endif()
+
 add_executable(vncviewer
   fltk/Fl_Monitor_Arrangement.cxx
   fltk/Fl_Navigation.cxx
index 951f16ad15959162e429cf3c39cc4568dc9e5749..6f0886d9eee122f878577a087aa5968a1918411b 100644 (file)
@@ -1,3 +1,7 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  message(FATAL_ERROR "cmake must be invoked with the top level directory")
+endif()
+
 include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/win)
 
 configure_file(resdefs.h.in ${CMAKE_CURRENT_BINARY_DIR}/resdefs.h)