Skip to content

Instantly share code, notes, and snippets.

@bruxisma
Created April 10, 2019 22:32
Show Gist options
  • Save bruxisma/6256fb20fe7b1f07729a025961bbee90 to your computer and use it in GitHub Desktop.
Save bruxisma/6256fb20fe7b1f07729a025961bbee90 to your computer and use it in GitHub Desktop.
GNU Make 4.2 for Windows (MinGW Confirmed)
cmake_minimum_required(VERSION 3.13)
project(gnu-make LANGUAGES C)
find_package(Threads REQUIRED)
# Currently builds without GNU Guile support.
if (WIN32)
configure_file(config.h.W32 ${PROJECT_BINARY_DIR}/config.h COPYONLY)
endif()
add_executable(make)
target_compile_definitions(make
PRIVATE
$<$<PLATFORM_ID:Windows>:WINDOWS32>
$<$<PLATFORM_ID:Windows>:HAVE_CONFIG_H>)
target_compile_features(make PRIVATE c_std_99)
list(APPEND windows-srcs
$<$<PLATFORM_ID:Windows>:w32/pathstuff.c>
$<$<PLATFORM_ID:Windows>:w32/w32os.c>
$<$<PLATFORM_ID:Windows>:w32/subproc/sub_proc.c>
$<$<PLATFORM_ID:Windows>:w32/subproc/w32err.c>
$<$<PLATFORM_ID:Windows>:w32/subproc/misc.c>
$<$<PLATFORM_ID:Windows>:w32/compat/posixfcn.c>
$<$<C_COMPILER_ID:MSVC>:w32/compat/dirent.c>)
target_sources(make PRIVATE
guile.c
main.c
ar.c
arscan.c
commands.c
default.c
dir.c
expand.c
file.c
function.c
getloadavg.c
getopt.c
getopt1.c
hash.c
implicit.c
job.c
load.c
loadapi.c
misc.c
output.c
read.c
remake.c
remote-stub.c
rule.c
signame.c
strcache.c
variable.c
version.c
vpath.c
glob/fnmatch.c
glob/glob.c
${windows-srcs})
target_include_directories(make
PRIVATE
$<$<PLATFORM_ID:Windows>:${PROJECT_SOURCE_DIR}/w32/include>
${PROJECT_SOURCE_DIR}/glob
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR})
target_link_libraries(make PRIVATE Threads::Threads)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment