From ccb75f65ab7277de3ac909981f4ba25e756030b3 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 15 Apr 2020 16:06:20 -0700 Subject: [PATCH] A couple of cmake cleanups. NFC. These are the NFC parts #10909. --- cmake/Modules/Platform/Emscripten.cmake | 18 +------------- tests/test_other.py | 32 +++++++------------------ 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/cmake/Modules/Platform/Emscripten.cmake b/cmake/Modules/Platform/Emscripten.cmake index ecb392295402f..ae7fb141ebc2d 100644 --- a/cmake/Modules/Platform/Emscripten.cmake +++ b/cmake/Modules/Platform/Emscripten.cmake @@ -206,28 +206,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_SYSTEM_INCLUDE_PATH "${EMSCRIPTEN_ROOT_PATH}/system/include") -# We would prefer to specify a standard set of Clang+Emscripten-friendly common -# convention for suffix files, especially for CMake executable files, but if -# these are adjusted, ${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake will fail, -# since it depends on being able to compile output files with predefined names. -#set(CMAKE_LINK_LIBRARY_SUFFIX "") -#set(CMAKE_STATIC_LIBRARY_PREFIX "") -#set(CMAKE_SHARED_LIBRARY_PREFIX "") -#set(CMAKE_FIND_LIBRARY_PREFIXES "") -#set(CMAKE_FIND_LIBRARY_SUFFIXES ".bc") -#set(CMAKE_SHARED_LIBRARY_SUFFIX ".bc") - option(EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES "If set, static library targets generate LLVM bitcode files (.bc). If disabled (default), UNIX ar archives (.a) are generated." OFF) if (EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES) set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc") - + # Use the compiler to create a bitcode object rather than the default of using the AR tool set(CMAKE_C_CREATE_STATIC_LIBRARY " -o ") set(CMAKE_CXX_CREATE_STATIC_LIBRARY " -o ") -else() - # Specify the program to use when building static libraries. Force - # Emscripten-related command line options to clang. - set(CMAKE_C_CREATE_STATIC_LIBRARY " rc ") - set(CMAKE_CXX_CREATE_STATIC_LIBRARY " rc ") endif() set(CMAKE_EXECUTABLE_SUFFIX ".js") diff --git a/tests/test_other.py b/tests/test_other.py index 31e810eb91f90..93b24ba289ce3 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -44,6 +44,10 @@ import tools.duplicate_function_eliminator scons_path = Building.which('scons') +if WINDOWS: + emcmake = path_from_root('emcmake.bat') +else: + emcmake = path_from_root('emcmake') class temp_directory(object): @@ -624,11 +628,6 @@ def check_makefile(dirname): } } - if WINDOWS: - emcmake = path_from_root('emcmake.bat') - else: - emcmake = path_from_root('emcmake') - for generator in generators: conf = configurations[generator] @@ -709,11 +708,6 @@ def test_cmake_compile_features(self): print(str(cmd)) native_features = run_process(cmd, stdout=PIPE).stdout - if WINDOWS: - emcmake = path_from_root('emcmake.bat') - else: - emcmake = path_from_root('emcmake') - with temp_directory(self.get_dir()): cmd = [emcmake, 'cmake', path_from_root('tests', 'cmake', 'stdproperty')] print(str(cmd)) @@ -727,7 +721,7 @@ def test_cmake_compile_features(self): def test_cmake_with_embind_cpp11_mode(self): for args in [[], ['-DNO_GNU_EXTENSIONS=1']]: with temp_directory(self.get_dir()) as tempdirname: - configure = [path_from_root('emcmake.bat' if WINDOWS else 'emcmake'), 'cmake', path_from_root('tests', 'cmake', 'cmake_with_emval')] + args + configure = [emcmake, 'cmake', path_from_root('tests', 'cmake', 'cmake_with_emval')] + args print(str(configure)) run_process(configure) build = ['cmake', '--build', '.'] @@ -743,15 +737,10 @@ def test_cmake_with_embind_cpp11_mode(self): # Tests that the Emscripten CMake toolchain option # -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=ON works. def test_cmake_bitcode_static_libraries(self): - if WINDOWS: - emcmake = path_from_root('emcmake.bat') - else: - emcmake = path_from_root('emcmake') - # Test that building static libraries by default generates UNIX archives (.a, with the emar tool) self.clear() run_process([emcmake, 'cmake', path_from_root('tests', 'cmake', 'static_lib')]) - run_process([Building.which('cmake'), '--build', '.']) + run_process(['cmake', '--build', '.']) assert Building.is_ar('libstatic_lib.a') run_process([PYTHON, EMAR, 'x', 'libstatic_lib.a']) found = False # hashing makes the object name random @@ -769,7 +758,7 @@ def test_cmake_bitcode_static_libraries(self): # (.bc) self.clear() run_process([emcmake, 'cmake', '-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=ON', path_from_root('tests', 'cmake', 'static_lib')]) - run_process([Building.which('cmake'), '--build', '.']) + run_process(['cmake', '--build', '.']) if self.is_wasm_backend(): assert Building.is_wasm('libstatic_lib.bc') else: @@ -781,16 +770,11 @@ def test_cmake_bitcode_static_libraries(self): # with ".so" suffix which are in fact either ar archives or bitcode files) self.clear() run_process([emcmake, 'cmake', '-DSET_FAKE_SUFFIX_IN_PROJECT=1', path_from_root('tests', 'cmake', 'static_lib')]) - run_process([Building.which('cmake'), '--build', '.']) + run_process(['cmake', '--build', '.']) assert Building.is_ar('myprefix_static_lib.somecustomsuffix') # Tests that the CMake variable EMSCRIPTEN_VERSION is properly provided to user CMake scripts def test_cmake_emscripten_version(self): - if WINDOWS: - emcmake = path_from_root('emcmake.bat') - else: - emcmake = path_from_root('emcmake') - run_process([emcmake, 'cmake', path_from_root('tests', 'cmake', 'emscripten_version')]) def test_system_include_paths(self):