diff --git a/CMakeLists.txt b/CMakeLists.txt index 92cf7b8690..b89e6a133b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.15) ################################################################################ # Project description # @@ -71,16 +71,17 @@ option(INSTALL_JSBSIM_PYTHON_MODULE "Set to ON to install the Python module for if (BUILD_PYTHON_MODULE) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/python/CMakeModules) + cmake_policy(SET CMP0094 NEW) # makes FindPython3 prefer activated virtualenv Python to the latest version + find_package(Python3 COMPONENTS Interpreter Development) find_package(Cython) if (CYTHON_FOUND) - find_package(PythonLibs) - if (PYTHONLIBS_FOUND) + if (Python3_Development_FOUND) enable_testing() add_subdirectory(tests) add_subdirectory(python) - endif(PYTHONLIBS_FOUND) - elseif(NOT PYTHONLIBS_FOUND) + endif(Python3_Development_FOUND) + elseif(NOT Python3_Development_FOUND) message(WARNING "JSBSim Python module and test suite will not be built") endif(CYTHON_FOUND) endif(BUILD_PYTHON_MODULE) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cd9c7dfe96..5d55e10713 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -5,6 +5,8 @@ include(UseCython) string(TIMESTAMP THIS_YEAR "%Y") # Declare JSBSim as a C++ project +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(JSBSIM_PYX ${CMAKE_CURRENT_BINARY_DIR}/_jsbsim.pyx) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jsbsim.pyx.in ${JSBSIM_PYX}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jsbsim.pxd ${CMAKE_CURRENT_BINARY_DIR}/_jsbsim.pxd COPYONLY) @@ -15,7 +17,7 @@ set_source_files_properties(${JSBSIM_PYX} PROPERTIES CYTHON_IS_CXX TRUE if(DOXYGEN_FOUND AND BUILD_DOCS) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxy2PyDocStrings.py doxy2pydocs.py) - execute_process(COMMAND ${PYTHON_EXECUTABLE} python/doxy2pydocs.py + execute_process(COMMAND ${Python3_EXECUTABLE} python/doxy2pydocs.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # Prepare the sphinx build files @@ -29,14 +31,6 @@ endif(DOXYGEN_FOUND AND BUILD_DOCS) compile_pyx(_jsbsim _JSBSIM_CXX ${JSBSIM_PYX}) file(RELATIVE_PATH JSBSIM_CXX ${CMAKE_CURRENT_BINARY_DIR} ${_JSBSIM_CXX}) -# Check if we are using Visual Studio msbuild -if(MSVC) - string(TOUPPER CMAKE_GENERATOR _GENERATOR) - if(NOT (_GENERATOR STREQUAL NINJA)) - set(USING_MSBUILD 1) - endif() -endif(MSVC) - # Build the package directory set(JSBSIM_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/jsbsim) file(MAKE_DIRECTORY ${JSBSIM_PACKAGE_DIR}) @@ -108,27 +102,21 @@ endforeach(_FILE) # been built. file(RELATIVE_PATH BUILD_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}) -set(SETUP_PY ${CMAKE_CURRENT_BINARY_DIR}/setup.py) -configure_file(setup.py.in ${SETUP_PY}) +configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) -execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/findModuleFileName.py _jsbsim OUTPUT_VARIABLE PYTHON_MODULE_NAME) -set(JSBSIM_PYTHON_MODULE ${JSBSIM_TEST_PACKAGE_DIR}/${PYTHON_MODULE_NAME}) +python3_add_library(_jsbsim MODULE ${JSBSIM_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/ExceptionManagement.h) +target_include_directories(_jsbsim PRIVATE ${PROJECT_SOURCE_DIR}/src) +target_link_libraries(_jsbsim PRIVATE libJSBSim) +set_target_properties(_jsbsim PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${JSBSIM_TEST_PACKAGE_DIR}) -# setup.py build_ext is called with --force because dependencies and time stamps -# are managed by CMake so we don't want setup.py to check them as well. -add_custom_command(OUTPUT ${JSBSIM_PYTHON_MODULE} - DEPENDS ${SETUP_PY} ${JSBSIM_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/ExceptionManagement.h $ - COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext -b ${JSBSIM_TEST_DIR} --force - $<$:--config> $<$:$> - $<$:--sharedlibs> - $<$:--compiler> $<$:mingw32> - COMMENT "Building Python module...") +# Output directories for MSVC +set_target_properties(_jsbsim PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${JSBSIM_TEST_PACKAGE_DIR}) +set_target_properties(_jsbsim PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${JSBSIM_TEST_PACKAGE_DIR}) +set_target_properties(_jsbsim PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${JSBSIM_TEST_PACKAGE_DIR}) +set_target_properties(_jsbsim PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${JSBSIM_TEST_PACKAGE_DIR}) add_subdirectory(fpectl) -add_custom_target(PythonJSBSim ALL DEPENDS ${JSBSIM_PYTHON_MODULE}) -add_dependencies(PythonJSBSim libJSBSim) - # Windows needs the DLL to be copied locally for unit tests to run. if(WIN32 AND BUILD_SHARED_LIBS) add_custom_command(OUTPUT ${JSBSIM_TEST_PACKAGE_DIR}/JSBSim.dll @@ -141,7 +129,7 @@ endif(WIN32 AND BUILD_SHARED_LIBS) # Install the JSBSim Python module if (INSTALL_JSBSIM_PYTHON_MODULE) - execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/findInstallDir.py OUTPUT_VARIABLE PYTHON_INSTALL_DIR) + execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/findInstallDir.py OUTPUT_VARIABLE PYTHON_INSTALL_DIR) file(MAKE_DIRECTORY ${PYTHON_INSTALL_DIR}/jsbsim) install(DIRECTORY ${JSBSIM_TEST_PACKAGE_DIR} DESTINATION ${PYTHON_INSTALL_DIR} COMPONENT pymodules) endif() diff --git a/python/CMakeModules/FindCython.cmake b/python/CMakeModules/FindCython.cmake index 7d28eb1408..66087f95bc 100644 --- a/python/CMakeModules/FindCython.cmake +++ b/python/CMakeModules/FindCython.cmake @@ -21,12 +21,13 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= +# +# Bertrand Coconnier 2023/03/25 - Rely on CMake FindPython3 to locate the Python executable # Use the Cython executable that lives next to the Python executable # if it is a local installation. -find_package( PythonInterp ) -if( PYTHONINTERP_FOUND ) - get_filename_component( _python_path ${PYTHON_EXECUTABLE} PATH ) +if(Python3_Interpreter_FOUND) + get_filename_component( _python_path ${Python3_EXECUTABLE} PATH ) find_program( CYTHON_EXECUTABLE NAMES cython cython.bat HINTS ${_python_path} diff --git a/python/CMakeModules/UseCython.cmake b/python/CMakeModules/UseCython.cmake index ec8db1cf13..f8a9e0a713 100644 --- a/python/CMakeModules/UseCython.cmake +++ b/python/CMakeModules/UseCython.cmake @@ -64,6 +64,7 @@ # # Bertrand Coconnier 2019/02/16 - Commented out the addition of include directories from the *.pyx path. # Bertrand Coconnier 2020/11/12 - Added the extraction of include directories from the *.pyx file. +# Bertrand Coconnier 2023/03/25 - Rely on CMake FindPython3 to locate the Python executable # Configuration options. set( CYTHON_ANNOTATE OFF @@ -75,7 +76,6 @@ set( CYTHON_FLAGS "" CACHE STRING mark_as_advanced( CYTHON_ANNOTATE CYTHON_NO_DOCSTRINGS CYTHON_FLAGS ) find_package( Cython REQUIRED ) -find_package( PythonLibs REQUIRED ) set( CYTHON_CXX_EXTENSION "cxx" ) set( CYTHON_C_EXTENSION "c" ) @@ -243,12 +243,12 @@ function( cython_add_module _name ) endif() endforeach() compile_pyx( ${_name} generated_file ${pyx_module_sources} ) - include_directories( ${PYTHON_INCLUDE_DIRS} ) + include_directories( ${Python3_INCLUDE_DIRS} ) python_add_module( ${_name} ${generated_file} ${other_module_sources} ) if( APPLE ) set_target_properties( ${_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" ) else() - target_link_libraries( ${_name} ${PYTHON_LIBRARIES} ) + target_link_libraries( ${_name} ${Python3_LIBRARIES} ) endif() endfunction() @@ -260,7 +260,7 @@ function( cython_add_standalone_executable _name ) set( other_module_sources "" ) set( main_module "" ) cmake_parse_arguments( cython_arguments "" "MAIN_MODULE" "" ${ARGN} ) - include_directories( ${PYTHON_INCLUDE_DIRS} ) + include_directories( ${Python3_INCLUDE_DIRS} ) foreach( _file ${cython_arguments_UNPARSED_ARGUMENTS} ) if( ${_file} MATCHES ".*\\.py[x]?$" ) get_filename_component( _file_we ${_file} NAME_WE ) @@ -286,5 +286,5 @@ function( cython_add_standalone_executable _name ) set( CYTHON_FLAGS ${CYTHON_FLAGS} --embed ) compile_pyx( "${main_module_we}_static" generated_file ${main_module} ) add_executable( ${_name} ${generated_file} ${pyx_module_sources} ${other_module_sources} ) - target_link_libraries( ${_name} ${PYTHON_LIBRARIES} ${pyx_module_libs} ) + target_link_libraries( ${_name} ${Python3_LIBRARIES} ${pyx_module_libs} ) endfunction() diff --git a/python/findModuleFileName.py b/python/findModuleFileName.py deleted file mode 100644 index 86a8a21903..0000000000 --- a/python/findModuleFileName.py +++ /dev/null @@ -1,10 +0,0 @@ -import sys - -from setuptools.command.build_ext import build_ext -from setuptools.dist import Distribution -from setuptools.extension import Extension - -ext = Extension(sys.argv[1], []) -name = build_ext(Distribution()).get_ext_filename(ext.name) - -sys.stdout.write(name) diff --git a/python/fpectl/CMakeLists.txt b/python/fpectl/CMakeLists.txt index 828f9d4b6e..ce03b87728 100644 --- a/python/fpectl/CMakeLists.txt +++ b/python/fpectl/CMakeLists.txt @@ -5,26 +5,26 @@ option(FPECTL_DISPLAY_STACK_TRACE "Set to ON to display the stack trace when a f if (APPLE) file(COPY fpectl.py DESTINATION ${CMAKE_BINARY_DIR}/tests) else() + python3_add_library(fpectl MODULE ${PROJECT_SOURCE_DIR}/python/ExceptionManagement.h + fpectlmodule.h + fpectlmodule.cpp) + set_target_properties(fpectl PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) + + # Output directories for MSVC + set_target_properties(fpectl PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/tests) + set_target_properties(fpectl PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/tests) + set_target_properties(fpectl PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/tests) + set_target_properties(fpectl PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/tests) + if(FPECTL_DISPLAY_STACK_TRACE) find_package(Backward) if(BACKWARD_FOUND) - set(FPECTL_INCLUDE_DIRS '${BACKWARD_INCLUDE_DIR}') + target_include_directories(fpectl PRIVATE ${BACKWARD_INCLUDE_DIR}) + target_compile_definitions(fpectl PRIVATE BACKWARD_FOUND) if(LIBBFD_FOUND) - set(FPECTL_LIBRARIES 'bfd') + target_link_libraries(fpectl PRIVATE bfd) + target_compile_definitions(fpectl PRIVATE LIBBFD_FOUND) endif(LIBBFD_FOUND) endif(BACKWARD_FOUND) endif(FPECTL_DISPLAY_STACK_TRACE) - - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fpectl_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/fpectl_config.h) - set(SETUP_PY ${CMAKE_CURRENT_BINARY_DIR}/setup.py) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${SETUP_PY}) - execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/findModuleFileName.py fpectl OUTPUT_VARIABLE FPECTL_MODULE_NAME) - set(FPECTL_PYTHON_MODULE ${CMAKE_BINARY_DIR}/tests/${FPECTL_MODULE_NAME}) - - add_custom_command(OUTPUT ${FPECTL_PYTHON_MODULE} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fpectlmodule.h ${CMAKE_CURRENT_SOURCE_DIR}/fpectlmodule.cpp ${PROJECT_SOURCE_DIR}/python/ExceptionManagement.h - COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext -b ${CMAKE_BINARY_DIR}/tests - COMMENT "Building fpectl module...") - - add_custom_target(fpectl ALL DEPENDS ${FPECTL_PYTHON_MODULE}) endif(APPLE) diff --git a/python/fpectl/fpectl_config.h.in b/python/fpectl/fpectl_config.h.in deleted file mode 100644 index 4ef4791b3c..0000000000 --- a/python/fpectl/fpectl_config.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#cmakedefine BACKWARD_FOUND -#cmakedefine LIBBFD_FOUND - -#ifdef LIBBFD_FOUND -#define BACKWARD_HAS_BFD 1 -#endif diff --git a/python/fpectl/fpectlmodule.cpp b/python/fpectl/fpectlmodule.cpp index 11290fb30c..1ac2d50ce8 100644 --- a/python/fpectl/fpectlmodule.cpp +++ b/python/fpectl/fpectlmodule.cpp @@ -66,7 +66,9 @@ ** Added the display of stack trace: July 11, 2021. Bertrand Coconnier */ -#include "fpectl_config.h" +#ifdef LIBBFD_FOUND +#define BACKWARD_HAS_BFD 1 +#endif #ifdef BACKWARD_FOUND #include "backward.hpp" #endif diff --git a/python/fpectl/setup.py.in b/python/fpectl/setup.py.in deleted file mode 100644 index a14a5d37cc..0000000000 --- a/python/fpectl/setup.py.in +++ /dev/null @@ -1,82 +0,0 @@ -# Setup script for the fpectl module. -# -# Copyright (c) 2014-2022 Bertrand Coconnier -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, see -# - -import logging -import os -import sys - -from setuptools import setup -from setuptools.extension import Extension -from setuptools.command.build_ext import build_ext -from setuptools._distutils.ccompiler import new_compiler -from setuptools.dist import Distribution - - -# Performs a build which verbosity is driven by VERBOSE -class QuietBuild(build_ext): - def run(self): - if "VERBOSE" not in os.environ: - name = self.extensions[0].name - logging.info("building '{}' extension".format(name)) - - self.oldstdout = os.dup(sys.stdout.fileno()) - self.devnull = open(name+'-build.log', 'w') - os.dup2(self.devnull.fileno(), sys.stdout.fileno()) - - build_ext.run(self) - - if "VERBOSE" not in os.environ: - os.dup2(self.oldstdout, sys.stdout.fileno()) - self.devnull.close() - -# Initialize the default logger to custom settings. -logging.basicConfig(level=logging.INFO, format='%(message)s') - -# Determine which compiler will be used to build the package. -dist = Distribution({'script_name': __file__}) - -if dist.parse_command_line() and 'build_ext' in dist.commands: - compiler_name = dist.get_command_obj('build_ext').compiler -else: - compiler_name = None - -compiler = new_compiler(compiler=compiler_name) - -if compiler.compiler_type == 'unix': - cpp_compile_flags = ['-std=c++11'] - cpp_link_flags = [] -elif compiler.compiler_type == 'msvc': - # These flags are equivalent to a RelWithDebInfo configuration. - # Since the module fpectl is not supposed to be used in production, these - # values are hardcoded. - cpp_compile_flags = ['/MD', '/Zi', '/O2', '/Ob1', '/DNDEBUG'] - cpp_link_flags = ['/debug', '/INCREMENTAL'] -else: - cpp_compile_flags = [] - cpp_link_flags = [] - -setup( - name="fpectl", - cmdclass={'build_ext': QuietBuild}, - ext_modules=[Extension('fpectl', - sources=['${CMAKE_CURRENT_SOURCE_DIR}/fpectlmodule.cpp'], - include_dirs=['${CMAKE_CURRENT_BINARY_DIR}', ${FPECTL_INCLUDE_DIRS}], - libraries=[${FPECTL_LIBRARIES}], - extra_compile_args=cpp_compile_flags, - extra_link_args=cpp_link_flags, - language='c++')]) diff --git a/python/setup.py.in b/python/setup.py.in index 4201149d85..47b17c91ff 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -16,14 +16,11 @@ # this program; if not, see # -import argparse -import logging import os -import sys -from argparse import ArgumentError from setuptools._distutils.ccompiler import new_compiler from setuptools._distutils.unixccompiler import UnixCCompiler +from setuptools._distutils import log from setuptools import setup from setuptools.command.build_ext import build_ext from setuptools.command.install_lib import install_lib @@ -31,23 +28,6 @@ from setuptools.dist import Distribution from setuptools.extension import Extension -# Performs a build which verbosity is driven by VERBOSE -class QuietBuild(build_ext): - def run(self): - if "VERBOSE" not in os.environ: - name = self.extensions[0].name - logging.info(f"building '{name}' extension") - - self.oldstdout = os.dup(sys.stdout.fileno()) - self.devnull = open(name+'-build.log', 'w') - os.dup2(self.devnull.fileno(), sys.stdout.fileno()) - - build_ext.run(self) - - if "VERBOSE" not in os.environ: - os.dup2(self.oldstdout, sys.stdout.fileno()) - self.devnull.close() - # When compiled with Microsoft Visual C++, the JSBSim Python module is linked # with the dynamically linked library msvcp140.dll which is not a standard # library on Windows. So this code allows msvcp140.dll to be shipped with the @@ -61,8 +41,9 @@ class InstallJSBSimModule(install_lib): libpath = os.path.join(d, msvcp_dll) if os.path.exists(libpath): if not os.path.exists(self.install_dir): - logging.info(f'creating {self.install_dir}') + log.info(f'creating {self.install_dir}') os.makedirs(self.install_dir) + log.info("copying %s -> %s", libpath, self.install_dir) self.copy_file(libpath, os.path.join(self.install_dir, msvcp_dll)) break @@ -100,46 +81,15 @@ class BuildC_CxxExtension(build_ext): setattr(self.compiler, attr, value) return build_ext.build_extension(self, ext) -# Initialize the default logger to custom settings. -logging.basicConfig(level=logging.INFO, format='%(message)s') - # Get the path to the JSBSim library. library_path = os.path.join('${BUILD_ROOT_PATH}', 'src') -# Intercept the --config option that we set for msbuild -parser = argparse.ArgumentParser(add_help=False) -parser.add_argument("--config", help="Build mode used by Visual C++", - choices=['Debug', 'Release', 'RelWithDebInfo']) -parser.add_argument("--sharedlibs", default=False, action="store_true", - help="specifies if JSBSim has been built with shared libs") -args, extra = parser.parse_known_args() - -if args.config or args.sharedlibs: - # Remove the option from the command line to prevent complaints from - # distutils - sys.argv[1:] = extra +compiler = new_compiler() -# Determine which compiler will be used to build the package. -dist = Distribution({'script_name': __file__}) - -if dist.parse_command_line() and 'build_ext' in dist.commands: - compiler_name = dist.get_command_obj('build_ext').compiler -else: - compiler_name = None - -compiler = new_compiler(compiler=compiler_name) - -# Update the JSBSim library path according to the --config option -# If the --config option has not been provided then we try getting the build -# configuration via the environment variable JSBSIM_BUILD_CONFIG. This feature -# is mainly useful for CI builds. -if compiler.compiler_type == 'msvc': - if not args.config and 'JSBSIM_BUILD_CONFIG' in os.environ: - args.config = os.environ['JSBSIM_BUILD_CONFIG'] - if args.config: - library_path=os.path.join(library_path, args.config) -elif args.config: - raise ArgumentError(None, 'option --config not recognized.') +# Update the JSBSim library path according to the environment variable +# JSBSIM_BUILD_CONFIG. This feature is mainly useful for CI builds. +if compiler.compiler_type == 'msvc' and 'JSBSIM_BUILD_CONFIG' in os.environ: + library_path=os.path.join(library_path, os.environ['JSBSIM_BUILD_CONFIG']) # It is good practice to provide library paths as absolute paths. library_path = os.path.abspath(library_path) @@ -148,28 +98,22 @@ convert_CMake_list_to_Python_list = lambda s: [item.strip() for item in s.split( # `cpp_compile_flag` is used for C++ compilation only (see class `C_CxxCompiler`) if compiler.compiler_type == 'unix': - cpp_compile_flag = ['-std=c++14'] + cpp_compile_flag = ['-std=c++14', '-DNDEBUG'] cpp_link_flags = [] link_libraries = convert_CMake_list_to_Python_list('${JSBSIM_LINK_LIBRARIES};${JSBSIM_UNIX_LINK_LIBRARIES}') elif compiler.compiler_type == 'msvc': - if args.config in ('Debug', 'RelWithDebInfo'): - # These flags are equivalent to a RelWithDebInfo configuration. - # Since the module fpectl is not supposed to be used in production, these - # values are hardcoded. - cpp_compile_flag = ['/MD', '/Zi', '/O2', '/Ob1', '/DNDEBUG'] - cpp_link_flags = ['/debug', '/INCREMENTAL'] - else: - cpp_compile_flag = [] - cpp_link_flags = [] - if not args.sharedlibs: - cpp_compile_flag.append('/DJSBSIM_STATIC_LINK') + cpp_compile_flag = ['/DJSBSIM_STATIC_LINK', '/DNDEBUG'] + cpp_link_flags = [] link_libraries = convert_CMake_list_to_Python_list('${JSBSIM_LINK_LIBRARIES};${JSBSIM_WINDOWS_LINK_LIBRARIES}') else: - cpp_compile_flag = [] + cpp_compile_flag = ['-DNDEBUG'] cpp_link_flags = [] link_libraries = convert_CMake_list_to_Python_list('${JSBSIM_LINK_LIBRARIES}') # Check if the library exists and build the Python module accordingly. +dist = Distribution({'script_name': __file__}) +dist.parse_command_line() + if 'sdist' not in dist.commands and compiler.find_library_file([library_path], 'JSBSim'): # OK, the JSBSim library has already been compiled so let's use it to build @@ -185,8 +129,7 @@ if 'sdist' not in dist.commands and compiler.find_library_file([library_path], 'library_dirs': [library_path], 'extra_compile_args': cpp_compile_flag, 'extra_link_args': cpp_link_flags } - setup_kwargs = { 'cmdclass' : {'build_ext': QuietBuild, - 'install_lib': InstallJSBSimModule}} + setup_kwargs = { 'cmdclass' : {'install_lib': InstallJSBSimModule}} else: # We cannot find the JSBSim library so the Python module must be built from # the sources. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8f63b02f3a..9a5ac98435 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -54,5 +54,5 @@ set(PYTHON_TESTS ResetOutputFiles foreach(test ${PYTHON_TESTS}) add_test(NAME ${test} - COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py) + COMMAND ${Python3_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py) endforeach()