$OpenBSD: patch-build_CMakeLists_txt,v 1.5 2015/05/15 08:23:20 bentley Exp $
--- build/CMakeLists.txt.orig	Wed Apr  8 15:20:21 2015
+++ build/CMakeLists.txt	Fri May 15 02:21:10 2015
@@ -33,48 +33,48 @@ if(DEBUG)
 			"-Wno-unused-const-variable")
 	endif()
 	join("${_arg_str}" CMAKE_C_FLAGS)
-else(DEBUG)
-	set(_arg_str "${CMAKE_C_FLAGS} -ansi -O2"
-		"-Wuninitialized"
-		"-Wstack-protector -fstack-protector")
-	if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
-		set(_arg_str "${_arg_str}"
-			"-Wno-dangling-else"
-			# avoid the "argument unused" error in clang
-			"-Qunused-arguments")
-	endif()
-	join("${_arg_str}" CMAKE_C_FLAGS)
+#else(DEBUG)
+#	set(_arg_str "${CMAKE_C_FLAGS} -ansi -O2"
+#		"-Wuninitialized"
+#		"-Wstack-protector -fstack-protector")
+#	if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+#		set(_arg_str "${_arg_str}"
+#			"-Wno-dangling-else"
+#			# avoid the "argument unused" error in clang
+#			"-Qunused-arguments")
+#	endif()
+#	join("${_arg_str}" CMAKE_C_FLAGS)
 endif(DEBUG)
 
 # commands to generate the public headers
 set(extract_protos sed -n 's/^ \\* PUBLIC: \\\(.*\\\)/\\1/p')
 set(extract_version sed -n
 	's/^.*version \\\([^\)]*\)\\\).*/\#define VI_VERSION \\\"\\1\\\"/p')
-add_custom_command(OUTPUT ../cl/extern.h
-	COMMAND ${extract_protos} ../cl/*.c > $@
-	DEPENDS ../cl/*.c)
-add_custom_command(OUTPUT ../common/extern.h
-	COMMAND ${extract_protos} ../common/*.c > $@
-	DEPENDS ../common/*.c)
-add_custom_command(OUTPUT ../ex/extern.h
-	COMMAND ${extract_protos} ../ex/*.c > $@
-	DEPENDS ../ex/*.c)
-add_custom_command(OUTPUT ../vi/extern.h
-	COMMAND ${extract_protos} ../vi/*.c > $@
-	DEPENDS ../vi/*.c)
-add_custom_command(OUTPUT ../common/options_def.h
-	COMMAND awk -f ../common/options.awk ../common/options.c > $@
-	DEPENDS ../common/options.c)
-add_custom_command(OUTPUT ../ex/ex_def.h
-	COMMAND awk -f ../ex/ex.awk ../ex/ex_cmd.c > $@
-	DEPENDS ../ex/ex_cmd.c)
-add_custom_command(OUTPUT ../ex/version.h
-	COMMAND ${extract_version} ../README > $@
-	DEPENDS ../README)
+add_custom_command(OUTPUT cl_extern.h
+	COMMAND ${extract_protos} *.c > cl_extern.h
+	WORKING_DIRECTORY ../cl/)
+add_custom_command(OUTPUT common_extern.h
+	COMMAND ${extract_protos} *.c > common_extern.h
+	WORKING_DIRECTORY ../common/)
+add_custom_command(OUTPUT ex_extern.h
+	COMMAND ${extract_protos} *.c > ex_extern.h
+	WORKING_DIRECTORY ../ex/)
+add_custom_command(OUTPUT vi_extern.h
+	COMMAND ${extract_protos} *.c > vi_extern.h
+	WORKING_DIRECTORY ../vi/)
+add_custom_command(OUTPUT options_def.h
+	COMMAND awk -f options.awk options.c > options_def.h
+	WORKING_DIRECTORY ../common/)
+add_custom_command(OUTPUT ex_def.h
+	COMMAND awk -f ex.awk ex_cmd.c > ex_def.h
+	WORKING_DIRECTORY ../ex/)
+add_custom_command(OUTPUT version.h
+	COMMAND ${extract_version} ../README > version.h
+	WORKING_DIRECTORY ../ex/)
 
 set(MAIN_PROTOS
-	../cl/extern.h ../common/extern.h ../ex/extern.h ../vi/extern.h
-	../common/options_def.h ../ex/ex_def.h ../ex/version.h)
+	cl_extern.h common_extern.h ex_extern.h vi_extern.h
+	options_def.h ex_def.h version.h)
 FILE(GLOB MAIN_SRCS ../cl/*.c ../common/*.c ../ex/*.c ../vi/*.c)
 FILE(GLOB REGEX_SRCS ../regex/reg*.c)
 
@@ -157,6 +157,7 @@ configure_file(${CMAKE_SOURCE_DIR}/recover.in
 	${CMAKE_SOURCE_DIR}/recover @ONLY)
 
 add_executable(nvi ${MAIN_SRCS} ${MAIN_PROTOS})
+add_dependencies(nvi headers)
 target_link_libraries(nvi ${CURSES_LIBRARY} ${UTIL_LIBRARY} ${RESOLV_LIBRARY})
 if(USE_WIDECHAR)
 	target_link_libraries(nvi regex)
