I was experimenting with CMake, until i stumped on this error:
CMake Error at CMakeLists.txt:34:
Parse error. Expected "(", got newline with text "
".
-- Configuring incomplete, errors occurred!
I though, ok fine, I'll fix the code at line 34, as suggested:
cmake_minimum_required(VERSION 3.10)
# set the project name
project(msv-auth VERSION 0.1)
# add the executable
add_executable(app "${CMAKE_CURRENT_SOURCE_DIR}/src/app.cpp")
# app name
get_target_property(Z_APP_NAME app NAME)
# specify compiler
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# specify C++ compiler flags
set(CMAKE_CXX_FLAGS -pthread)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -o\"${CMAKE_CURRENT_SOURCE_DIR}/target/debug/${Z_APP_NAME}\")
else()
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -O3)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -o\"${CMAKE_CURRENT_SOURCE_DIR}/target/release/${Z_APP_NAME}\")
endif()
#includes
target_include_directories(app INTERFACE "/usr/local/include/oatpp-1.3/oatpp")
#libs
target_link_directories(app INTERFACE "/usr/local/oatpp-1.3.0")
target_link_libraries(app oatpp)
But I can't seem able to fix that error even after I tried multiple times. OK, I though, let's simplify things a bit, and make a completely new CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
# set the project name
project(msv-auth VERSION 0.1)
# add the executable
add_executable(app "${CMAKE_CURRENT_SOURCE_DIR}/src/app.cpp")
# specify compiler
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
# specify C++ compiler flags
set(CMAKE_CXX_FLAGS -pthread)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -o\"${CMAKE_CURRENT_SOURCE_DIR}/target/debug/app\")
#includes
target_include_directories(app INTERFACE "/usr/local/include/oatpp-1.3/oatpp")
#libs
target_link_directories(app INTERFACE "/usr/local/oatpp-1.3.0")
target_link_libraries(app oatpp)
(There is only 23 lines of code in the 2nd CMakeLists.txt file)
However, running cmake .., it produced this error:
CMake Error at CMakeLists.txt:34:
Parse error. Expected "(", got newline with text "
".
-- Configuring incomplete, errors occurred!
Exactly the same error on the same exact line number! Like, how can there be an error on line 34 if there's only 23 lines on the file?!
Even creating a new folder, renaming every file, or even running a completely different CMakeLists.txt on a completely different folder for a completely different project, produced the same exact error message. Even rebooting the computer did not fix it at all. I've even tried uninstall and installing CMake again, still the same issue.
Anyone ever stumped on this kind of error? How did you fix it?