chiark / gitweb /
Advertise user-configurable cmake-time config options.
authorSimon Tatham <anakin@pobox.com>
Sun, 4 Apr 2021 13:58:39 +0000 (14:58 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 4 Apr 2021 13:58:39 +0000 (14:58 +0100)
Various cmake variables that I was informally expecting users to set
on the cmake command line (e.g. cmake -DSTRICT=ON, or cmake
-DPUZZLES_GTK_VERSION=2) are now labelled explicitly with the CACHE
tag, and provided with a documentation string indicating what they're
for.

One effect of this is that GUI-like interfaces to your cmake build
directory, such as ccmake or cmake-gui, will show those variables
explicitly to give you a hint that you might want to change them.

Another is that when you do change them, cmake will recognise that it
needs to redo the rest of its configuration. Previously, if you sat in
an existing cmake build directory and did 'cmake -DSTRICT=ON .'
followed by 'cmake -DSTRICT=OFF .', nothing would happen, even though
you obviously meant it to.

cmake/platforms/unix.cmake
cmake/setup.cmake

index 6cbcbe44764730ba2a5f0b422cf2e60317d31033..17d539dbe8341fe6c95f2fa4965a888ed01969ba 100644 (file)
@@ -1,10 +1,22 @@
+set(PUZZLES_GTK_VERSION "ANY"
+  CACHE STRING "Which major version of GTK to build with")
+set_property(CACHE PUZZLES_GTK_VERSION
+  PROPERTY STRINGS ANY 3 2 1)
+
+set(STRICT OFF
+  CACHE BOOL "Enable extra compiler warnings and make them errors")
+
+set(NAME_PREFIX ""
+  CACHE STRING "Prefix to prepend to puzzle binary names to avoid clashes \
+in a crowded bin directory, e.g. \"sgt-\"")
+
 find_package(PkgConfig REQUIRED)
 
 set(PUZZLES_GTK_FOUND FALSE)
 macro(try_gtk_package VER PACKAGENAME)
   if(NOT PUZZLES_GTK_FOUND AND
-      (NOT DEFINED PUZZLES_GTK_VERSION OR
-        PUZZLES_GTK_VERSION STREQUAL ${VER}))
+      (PUZZLES_GTK_VERSION STREQUAL ANY OR
+       PUZZLES_GTK_VERSION STREQUAL ${VER}))
     pkg_check_modules(GTK ${PACKAGENAME})
     if(GTK_FOUND)
       set(PUZZLES_GTK_FOUND TRUE)
@@ -35,8 +47,8 @@ if(CMAKE_CROSSCOMPILING)
   set(build_icons FALSE)
 endif()
 
-if(DEFINED STRICT AND (CMAKE_C_COMPILER_ID MATCHES "GNU" OR
-                       CMAKE_C_COMPILER_ID MATCHES "Clang"))
+if(STRICT AND (CMAKE_C_COMPILER_ID MATCHES "GNU" OR
+               CMAKE_C_COMPILER_ID MATCHES "Clang"))
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wwrite-strings -std=c99 -pedantic -Werror")
 endif()
 
index d9c766336621ac209c0d80ebce5cff38114e6c88..0ccf34500421a28d96df84690b7baf4b8cf69a65 100644 (file)
@@ -1,3 +1,7 @@
+set(PUZZLES_ENABLE_UNFINISHED ""
+  CACHE STRING "List of puzzles in the 'unfinished' subdirectory \
+to build as if official (separated by ';')")
+
 set(build_individual_puzzles TRUE)
 set(build_cli_programs TRUE)
 set(build_icons FALSE)