cmake: Only use the `cm_` prefix when it is actually required (fixes #8955)

pull/8967/head
Daniel Mensinger 4 years ago committed by Jussi Pakkanen
parent 50f870e361
commit 0d0f2cdafd
  1. 5
      mesonbuild/cmake/interpreter.py
  2. 2
      test cases/cmake/19 advanced options/test.json
  3. 4
      test cases/cmake/2 advanced/meson.build
  4. 2
      test cases/cmake/2 advanced/test.json
  5. 5
      test cases/cmake/3 advanced no dep/meson.build
  6. 10
      test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt
  7. 8
      test cases/cmake/3 advanced no dep/test.json

@ -26,6 +26,7 @@ from ..mesonlib import MachineChoice, OrderedSet, version_compare, path_is_in_ro
from ..mesondata import mesondata
from ..compilers.compilers import assembler_suffixes, lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header
from ..programs import ExternalProgram
from ..coredata import FORBIDDEN_TARGET_NAMES
from enum import Enum
from functools import lru_cache
from pathlib import Path
@ -120,7 +121,9 @@ transfer_dependencies_from = ['header_only']
_cmake_name_regex = re.compile(r'[^_a-zA-Z0-9]')
def _sanitize_cmake_name(name: str) -> str:
name = _cmake_name_regex.sub('_', name)
return 'cm_' + name
if name in FORBIDDEN_TARGET_NAMES or name.startswith('meson'):
name = 'cm_' + name
return name
class OutputTargetMap:
rm_so_version = re.compile(r'(\.[0-9]+)+$')

@ -1,6 +1,6 @@
{
"installed": [
{"type": "exe", "file": "usr/bin/cm_testEXE"}
{"type": "exe", "file": "usr/bin/testEXE"}
],
"tools": {
"cmake": ">=3.11"

@ -21,3 +21,7 @@ test('test2', exe2)
# Test if we can also extract executables
assert(sub_pro.target_type('testEXE') == 'executable', 'The type must be executable for obvious reasons')
test('test3', sub_pro.target('testEXE'))
# Test that we can add a new target with the same name as the CMake subproject
exe4 = executable('testEXE', ['main.cpp'], dependencies: [sub_sta])
test('test4', exe4)

@ -1,6 +1,6 @@
{
"installed": [
{"type": "exe", "file": "usr/bin/cm_testEXE"}
{"type": "exe", "file": "usr/bin/testEXE"}
],
"tools": {
"cmake": ">=3.11"

@ -14,5 +14,6 @@ test('test1', exe1)
test('test2', exe2)
# Test if we can also extract executables
assert(sub_pro.target_type('testEXE') == 'executable', 'The type must be executable for obvious reasons')
test('test3', sub_pro.target('testEXE'))
assert(sub_pro.target_type('meson-testEXE') == 'executable', 'The type must be executable for obvious reasons')
test('test3', sub_pro.target('meson-testEXE'))
test('test4', sub_pro.target('benchmark'))

@ -15,12 +15,12 @@ generate_export_header(cmModLib)
set_target_properties(cmModLib PROPERTIES VERSION 1.0.1)
add_executable(testEXE main.cpp)
add_executable(testEXE2 main.cpp)
add_executable(meson-testEXE main.cpp)
add_executable(benchmark main.cpp)
target_link_libraries(testEXE cmModLib)
target_link_libraries(testEXE2 cmModLib)
target_link_libraries(meson-testEXE cmModLib)
target_link_libraries(benchmark cmModLib)
target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE)
install(TARGETS testEXE testEXE2 LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
install(TARGETS meson-testEXE benchmark LIBRARY DESTINATION lib RUNTIME DESTINATION bin)

@ -1,9 +1,9 @@
{
"installed": [
{"type": "pdb", "file": "usr/bin/cm_testEXE"},
{"type": "exe", "file": "usr/bin/cm_testEXE"},
{"type": "pdb", "file": "usr/bin/cm_testEXE2"},
{"type": "exe", "file": "usr/bin/cm_testEXE2"}
{"type": "pdb", "file": "usr/bin/cm_meson_testEXE"},
{"type": "exe", "file": "usr/bin/cm_meson_testEXE"},
{"type": "pdb", "file": "usr/bin/cm_benchmark"},
{"type": "exe", "file": "usr/bin/cm_benchmark"}
],
"tools": {
"cmake": ">=3.11"

Loading…
Cancel
Save