diff --git a/config.w32 b/config.w32 index 4aef3bd6..00c25823 100644 --- a/config.w32 +++ b/config.w32 @@ -1,24 +1,35 @@ // vim:ft=javascript -ARG_ENABLE("couchbase", "weather to enable Couchbase support", "no"); +ARG_ENABLE("couchbase", "whether to enable Couchbase support", "no"); if (PHP_COUCHBASE != "no") { - var CMAKE = PATH_PROG("cmake"); + // we prefer standalone CMake, as the one that comes with MSVS might be too old + var CMAKE = PATH_PROG("cmake", PROGRAM_FILES + "\\CMake\\bin;" + PROGRAM_FILESx86 + "\\CMake\\bin"); if (!CMAKE) { ERROR("cmake is required"); } + var LOCALAPPDATA = WshShell.Environment("Process").Item("LOCALAPPDATA"); + var NASM = PATH_PROG("nasm", LOCALAPPDATA + "\\bin\\nasm"); + if (!NASM) { + ERROR("nasm is required for BoringSSL"); + } ADD_FLAG("CFLAGS", "/std:c++17"); var COUCHBASE_CMAKE_SOURCE_DIRECTORY = FSO.GetAbsolutePathName(configure_module_dirname + "\\src"); var COUCHBASE_CMAKE_BUILD_DIRECTORY = get_define("BUILD_DIR") + "\\cmake-build"; - var COUCHBASE_PHP_CFLAGS = (get_define("CFLAGS_PHP") + " " + get_define("CFLAGS")) + // TODO: we don't seem to need this: get_define("CFLAGS_PHP") + var COUCHBASE_PHP_CFLAGS = get_define("CFLAGS") .replace('$(BASE_INCLUDES)', '') + .replace(new RegExp('"', 'g'), '\\"') .replace(new RegExp('\\s+', 'g'), ' ') .replace(new RegExp('/D ', 'g'), '/D') .replace(new RegExp('/I ', 'g'), '/I'); STDOUT.WriteLine('MODE_PHPIZE=' + MODE_PHPIZE); - STDOUT.WriteLine('PHP_DIR="' + PHP_DIR + '"'); STDOUT.WriteLine('PHP_SRC_DIR="' + PHP_SRC_DIR + '"'); - var php_src_prefix = MODE_PHPIZE ? PHP_DIR + "\\include" : PHP_SRC_DIR; + STDOUT.WriteLine('BUILD_DIR="' + get_define("BUILD_DIR") + '"'); + if (MODE_PHPIZE) { + STDOUT.WriteLine('PHP_DIR="' + PHP_DIR + '"'); + } + var php_src_prefix = MODE_PHPIZE ? (PHP_DIR + "\\include") : PHP_SRC_DIR; var COUCHBASE_PHP_INCLUDES = php_src_prefix + " " + php_src_prefix + "\\main " + @@ -26,10 +37,11 @@ if (PHP_COUCHBASE != "no") { php_src_prefix + "\\TSRM " + php_src_prefix + "\\ext"; var COUCHBASE_PHP_LIB = - MODE_PHPIZE ? PHP_DIR + "\\lib" : get_define("BUILD_DIR") + + (MODE_PHPIZE ? PHP_DIR + "\\lib" : get_define("BUILD_DIR")) + "\\" + get_define("PHPLIB"); STDOUT.WriteLine('CMAKE="' + CMAKE + '" # version: ' + probe_binary(CMAKE, "longversion")); + STDOUT.WriteLine('NASM="' + NASM + '" # version: ' + probe_binary(NASM, "version")); STDOUT.WriteLine('COUCHBASE_CMAKE_SOURCE_DIRECTORY="' + COUCHBASE_CMAKE_SOURCE_DIRECTORY + '"'); STDOUT.WriteLine('COUCHBASE_CMAKE_BUILD_DIRECTORY="' + COUCHBASE_CMAKE_BUILD_DIRECTORY + '"'); STDOUT.WriteLine('COUCHBASE_PHP_CFLAGS="' + COUCHBASE_PHP_CFLAGS + '"'); @@ -40,17 +52,18 @@ if (PHP_COUCHBASE != "no") { DEFINE("DEPS_COUCHBASE", get_define("LIBS_COUCHBASE")); EXTENSION("couchbase", "src\\php_couchbase.cxx", true); - MFO.WriteLine("$(BUILD_DIR)\\couchbase_php_wrapper.lib: $(BUILD_DIR)\\$(PHPDLL)"); - MFO.WriteLine("\t" + CMAKE + " --build " + COUCHBASE_CMAKE_BUILD_DIRECTORY + " --parallel 4 --verbose"); + MFO.WriteLine("$(BUILD_DIR)\\couchbase_php_wrapper.lib: " + (MODE_PHPIZE ? "" : "$(BUILD_DIR)\\$(PHPDLL)")); + MFO.WriteLine("\t\"" + CMAKE + "\" --build \"" + COUCHBASE_CMAKE_BUILD_DIRECTORY + "\" --verbose"); MFO.WriteLine("couchbase_php_wrapper.lib: $(BUILD_DIR)\\couchbase_php_wrapper.lib"); MFO.WriteLine("\t@echo EXT couchbase wrapper build complete"); cmake_command = - 'cmd /c ' + CMAKE + - ' -S ' + COUCHBASE_CMAKE_SOURCE_DIRECTORY + - ' -B ' + COUCHBASE_CMAKE_BUILD_DIRECTORY + - ' -G ' + '"NMake Makefiles"' + + 'cmd /c ""' + CMAKE + '"' + + ' -S "' + COUCHBASE_CMAKE_SOURCE_DIRECTORY + '"' + + ' -B "' + COUCHBASE_CMAKE_BUILD_DIRECTORY + '"' + + ' -G "NMake Makefiles"' + ' -D CMAKE_BUILD_TYPE=RelWithDebInfo' + + ' -D CMAKE_ASM_NASM_COMPILER:PATH="' + NASM + '"' + ' -D COUCHBASE_PHP_CFLAGS="' + COUCHBASE_PHP_CFLAGS + '"' + ' -D COUCHBASE_PHP_INCLUDES="' + COUCHBASE_PHP_INCLUDES + '"' + ' -D COUCHBASE_PHP_LIB="' + COUCHBASE_PHP_LIB + '"' + @@ -58,7 +71,7 @@ if (PHP_COUCHBASE != "no") { ' -D COUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF ' + ' -D COUCHBASE_CXX_CLIENT_BUILD_TOOLS=OFF ' + ' -D COUCHBASE_CXX_CLIENT_BUILD_DOCS=OFF ' + - ' -D COUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF 2>&1'; + ' -D COUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF" 2>&1'; STDOUT.WriteLine(cmake_command); cmake_output = execute(cmake_command); STDOUT.WriteLine(cmake_output); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dadab762..78bb39ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,9 @@ -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.27) +if(POLICY CMP0149) + # BoringSSL requires at least WindowsSDKVersion=10.0.20348.0 + cmake_policy(SET CMP0149 NEW) +endif() + project(couchbase C CXX) set(CMAKE_CXX_STANDARD 17)