当我从终端 cmake .. 时,错误如下所示:
(base) k:~ cd /Users/yuli/Documents/version3/cpp/
(base) k:~ ls
CMakeLists.txt src
riscv-gnu-toolchain test
(base) k:~ mkdir build
(base) k:~ cd build
(base) k:~ cmake ..
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
CMake Error at CMakeLists.txt:10 (if):
if given arguments:
"/Library/Developer/CommandLineTools/usr/bin/c++" "MATCHES" ".*riscv64-unknown-elf-g++"
Regular expression ".*riscv64-unknown-elf-g++" cannot compile
-- Configuring incomplete, errors occurred!
See also "/Users/yuli/Documents/version3/cpp/build/CMakeFiles/CMakeOutput.log".
我尝试了“STREQUAL”而不是 MATCHES,但没有奏效。知道这里可能有什么问题吗?
CMakeLists.txt 如下:
cmake_minimum_required(VERSION 3.13)
project(ofdmchain)
set(CMAKE_CXX_FLAGS "-std=c++14")
add_definitions(-DCOMPILES_ON_PC -Wall -Wextra)
configure_file(${CMAKE_SOURCE_DIR}/src/config.hpp.in ${CMAKE_BINARY_DIR}/config.hpp)
if("${CMAKE_CXX_COMPILER}" MATCHES ".*riscv64-unknown-elf-g++")
message(STATUS "Compiling RISCV")
SET(RISCV 1)
else()
message(STATUS "Compiling X86")
SET(RISCV 0)
endif()
add_library(ofdm
src/transmitter.cpp
src/configuration.cpp
src/ofdm.hpp
src/datatypes.hpp
)
target_include_directories(ofdm PRIVATE ${CMAKE_SOURCE_DIR}/../reference_matlab)
target_include_directories(ofdm PRIVATE ${CMAKE_SOURCE_DIR}/src/)
if (NOT ${RISCV})
add_executable(unit_tests
test/catch_main.cpp
test/test_sanity.cpp
test/test_utilities.cpp
test/test_transmitter.cpp
)
target_include_directories(unit_tests PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(unit_tests PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(unit_tests ofdm)
endif()
我还尝试在 g++ 退出的地方以及 - where - 存在的地方添加 ++。并且也厌倦了“STREQUAL”而不是“MATCHES”,它也不起作用。可能是PATH中c++的问题?