From 069c79b5b5515591cca0ad9f6538b6e260720484 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Thu, 16 May 2024 10:52:46 +0200 Subject: [PATCH] Allow building fmusim with VisualStudio 2019 (#504) fixes #493 --- build/build.py | 13 +++++++++---- build/build_cvode.py | 13 +++++++++---- build/build_libxml2.py | 13 +++++++++---- build/build_zlib.py | 12 +++++++++--- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/build/build.py b/build/build.py index d74323b3..9b2de884 100644 --- a/build/build.py +++ b/build/build.py @@ -15,7 +15,12 @@ choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, help="Platform to build for, e.g. x86_64-windows" ) -parser.add_argument('--cmake-generator') +parser.add_argument( + '--cmake-generator', + choices={'Visual Studio 17 2022', 'Visual Studio 16 2019'}, + default='Visual Studio 17 2022', + help="CMake generator for Windows" +) args, _ = parser.parse_known_args() @@ -38,12 +43,12 @@ def build_fmus(fmi_version, fmi_type=None): if fmi_system == 'windows': - cmake_generator = 'Visual Studio 17 2022' if args.cmake_generator is None else args.cmake_generator + cmake_args += ['-G', args.cmake_generator] if fmi_architecture == 'x86': - cmake_args += ['-G', cmake_generator, '-A', 'Win32'] + cmake_args += ['-A', 'Win32'] elif fmi_architecture == 'x86_64': - cmake_args += ['-G', cmake_generator, '-A', 'x64'] + cmake_args += ['-A', 'x64'] elif fmi_platform == 'aarch64-linux': diff --git a/build/build_cvode.py b/build/build_cvode.py index c3246520..4d975080 100644 --- a/build/build_cvode.py +++ b/build/build_cvode.py @@ -11,6 +11,12 @@ choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, help="Platform to build for, e.g. x86_64-windows" ) +parser.add_argument( + '--cmake-generator', + choices={'Visual Studio 17 2022', 'Visual Studio 16 2019'}, + default='Visual Studio 17 2022', + help="CMake generator for Windows" +) args, _ = parser.parse_known_args() archive = download_file('https://github.com/LLNL/sundials/releases/download/v6.4.1/cvode-6.4.1.tar.gz', @@ -33,16 +39,15 @@ if fmi_system == 'windows': cmake_args = [ - '-G', 'Visual Studio 17 2022', + '-G', args.cmake_generator, '-D', 'CMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG', '-D', 'CMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1', - '-A' ] if fmi_architecture == 'x86': - cmake_args.append('Win32') + cmake_args += ['-A', 'Win32'] elif fmi_architecture == 'x86_64': - cmake_args.append('x64') + cmake_args += ['-A', 'x64'] elif fmi_platform == 'aarch64-linux': diff --git a/build/build_libxml2.py b/build/build_libxml2.py index 4287d0cb..dc1b60a7 100644 --- a/build/build_libxml2.py +++ b/build/build_libxml2.py @@ -11,6 +11,12 @@ choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, help="Platform to build for, e.g. x86_64-windows" ) +parser.add_argument( + '--cmake-generator', + choices={'Visual Studio 17 2022', 'Visual Studio 16 2019'}, + default='Visual Studio 17 2022', + help="CMake generator for Windows" +) (args, _) = parser.parse_known_args() archive = download_file('https://github.com/GNOME/libxml2/archive/refs/tags/v2.11.5.zip', @@ -32,15 +38,14 @@ if fmi_system == 'windows': cmake_args = [ - '-G', 'Visual Studio 17 2022', + '-G', args.cmake_generator, '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', - '-A' ] if fmi_architecture == 'x86': - cmake_args.append('Win32') + cmake_args += ['-A', 'Win32'] elif fmi_architecture == 'x86_64': - cmake_args.append('x64') + cmake_args += ['-A', 'x64'] elif fmi_platform == 'aarch64-linux': diff --git a/build/build_zlib.py b/build/build_zlib.py index c26f7cee..2e7353be 100644 --- a/build/build_zlib.py +++ b/build/build_zlib.py @@ -10,6 +10,12 @@ choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, help="Platform to build for, e.g. x86_64-windows" ) +parser.add_argument( + '--cmake-generator', + choices={'Visual Studio 17 2022', 'Visual Studio 16 2019'}, + default='Visual Studio 17 2022', + help="CMake generator for Windows" +) args, _ = parser.parse_known_args() archive = download_file('https://www.zlib.net/fossils/zlib-1.3.tar.gz', @@ -31,12 +37,12 @@ if fmi_system == 'windows': - cmake_args += ['-G', 'Visual Studio 17 2022', '-A'] + cmake_args += ['-G', args.cmake_generator] if fmi_architecture == 'x86': - cmake_args.append('Win32') + cmake_args += ['-A', 'Win32'] elif fmi_architecture == 'x86_64': - cmake_args.append('x64') + cmake_args += ['-A', 'x64'] cmake_args += [ '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded'