summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt67
1 files changed, 34 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9451eaa89799..cdb5ed4eb32f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,10 +42,6 @@ add_compile_options(-Wstrict-aliasing -fstrict-aliasing)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-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)
-
set(CL_SRCS
cl/cl_funcs.c cl/cl_main.c cl/cl_read.c cl/cl_screen.c cl/cl_term.c)
@@ -81,44 +77,59 @@ set(VI_SRCS
set(REGEX_SRCS
regex/regcomp.c regex/regerror.c regex/regexec.c regex/regfree.c)
+set(GENERATED_HDRS
+ ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
+ ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+
# 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_SRCS} > cl/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
+ COMMAND ${extract_protos} ${CL_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CL_SRCS})
-add_custom_command(OUTPUT common/extern.h
- COMMAND ${extract_protos} ${COMMON_SRCS} > common/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
+ COMMAND ${extract_protos} ${COMMON_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${COMMON_SRCS})
-add_custom_command(OUTPUT ex/extern.h
- COMMAND ${extract_protos} ${EX_SRCS} > ex/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
+ COMMAND ${extract_protos} ${EX_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${EX_SRCS})
-add_custom_command(OUTPUT vi/extern.h
- COMMAND ${extract_protos} ${VI_SRCS} > vi/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
+ COMMAND ${extract_protos} ${VI_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${VI_SRCS})
-add_custom_command(OUTPUT common/options_def.h
- COMMAND awk -f common/options.awk
- common/options.c > common/options_def.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
+ COMMAND awk -f common/options.awk common/options.c >
+ ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS common/options.c)
-add_custom_command(OUTPUT ex/ex_def.h
- COMMAND awk -f ex/ex.awk ex/ex_cmd.c > ex/ex_def.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
+ COMMAND awk -f ex/ex.awk ex/ex_cmd.c >
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ex/ex_cmd.c)
-add_custom_command(OUTPUT ex/version.h
- COMMAND ${extract_version} README > ex/version.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ COMMAND ${extract_version} README >
+ ${CMAKE_CURRENT_BINARY_DIR}/version.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS README)
add_executable(nvi)
-target_sources(nvi PRIVATE ${MAIN_PROTOS} ${CL_SRCS} ${COMMON_SRCS}
- ${EX_SRCS} ${VI_SRCS})
+target_sources(nvi PRIVATE ${CL_SRCS} ${COMMON_SRCS} ${EX_SRCS} ${VI_SRCS}
+ ${GENERATED_HDRS})
target_compile_definitions(nvi PRIVATE $<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:Debug>:COMLOG>)
@@ -208,18 +219,8 @@ check_function_exists(dbopen DBOPEN_IN_LIBC)
if(NOT DBOPEN_IN_LIBC)
target_link_libraries(nvi PRIVATE db1)
endif()
-if (APPLE)
- # Avoid using an incompatible db.h installed to /usr/local (since this is
- # part of the default search path on macOS)
- set(DB_H_GUESS "${CMAKE_OSX_SYSROOT}/usr/include/db.h")
- if (NOT EXISTS ${DB_H_GUESS})
- message(FATAL_ERROR "Could not find db.h at the expected path (${DB_H_GUESS}).")
- endif()
- add_definitions("-DDB_H_ABS_PATH=<${DB_H_GUESS}>")
-else()
- find_path(DB_INCLUDE_DIR db.h PATH_SUFFIXES db1)
- target_include_directories(nvi PRIVATE ${DB_INCLUDE_DIR})
-endif()
+find_path(DB_INCLUDE_DIR db.h PATH_SUFFIXES db1)
+target_include_directories(nvi PRIVATE ${DB_INCLUDE_DIR})
check_include_files(libutil.h HAVE_LIBUTIL_H)
check_include_files(ncurses.h HAVE_NCURSES_H)