Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

cmake execute_process sed no such file or directory error

I need to use rapidjson in my project. The CMakeLists.txt has a -march=native setting. However I'm cross-compiling my code. I figure if I remove this option I should be able to compile the code with no issues. I wrote a simple CMakeLists.txt which would remove this option, however it didn't work. Here is my code:

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(test)

include(FetchContent)
set(REPO "https://github.com/Tencent/rapidjson.git")
message(STATUS "Fetching ${REPO}")
FetchContent_Declare(
    rapidjson
    GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
    GIT_TAG        v1.1.0
)
FetchContent_GetProperties(rapidjson)

if(NOT rapidjson_POPULATED)
    FetchContent_Populate(rapidjson)
    add_subdirectory(${rapidjson_SOURCE_DIR} ${rapidjson_BINARY_DIR})
endif()

execute_process(
    COMMAND "sed -i 's/-march=native//g' ${rapidjson_SOURCE_DIR}/CMakeLists.txt"
    OUTPUT_VARIABLE out
    RESULT_VARIABLE res
    ERROR_VARIABLE err
)

message(STATUS ${rapidjson_SOURCE_DIR}/CMakeLists.txt)
message(STATUS ${out})
message(STATUS ${res})
message(STATUS ${err})

The output of this code looks like the following:

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Fetching https://github.com/Tencent/rapidjson.git
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- No Doxygen found. Documentation won't be built
-- Found GTestSrc: /tmp/cmake-test/build/_deps/rapidjson-src/thirdparty/gtest/googletest  
-- Found PythonInterp: /usr/bin/python (found version "2.7.18") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- =================================================
-- /tmp/cmake-test/build/_deps/rapidjson-src/CMakeLists.txt
-- 
-- No such file or directory
-- 
-- =================================================
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/cmake-test/build

Based on

-- =================================================
-- /tmp/cmake-test/build/_deps/rapidjson-src/CMakeLists.txt
-- 
-- No such file or directory
-- 
-- =================================================

there was an error, but I don't understand why. The file clearly exists, but why CMake is telling me that it doesn't, that's what I can't figure out.

Does anyone know what is the issue? Why the solution above doesn't work?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...