Reputation: 107
I'm working on a project which have following architecture.
sync
|--- CMakeLists.txt
|--- SyncManager
|--- CMakeLists.txt
|--- src
|--- SyncCommon
|--- CMakeLists.txt
|--- src
|--- SyncProcessor
|--- CMakeLists.txt
|--- src
Both SyncManager and SyncProcessor use functions in SyncCommon. Contents of CMakeLists.txt are as follow.
sync/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(sync)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_subdirectory(SyncManager)
add_subdirectory(SyncProcessor)
add_subdirectory(SyncCommon)
sync/SyncManager/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(SyncManager VERSION 2.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
file(GLOB project_SRCS src/*.cpp src/*.h)
include_directories(src/ ../SyncCommon/src)
add_executable(syncManager ${project_SRCS})
target_link_libraries(syncManager syncCommon)
sync/SyncCommon/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(ingester VERSION 2.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS " -g -Wall -O2 -w -fpermissive -pthread")
file(GLOB project_SRCS src/*.cpp src/*.h mhmc/*.c mhmc/*.h)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/src/cmake/")
find_package(MYSQL REQUIRED)
find_package(CURL REQUIRED)
add_library(syncCommon STATIC ${project_SRCS})
target_include_directories(syncCommon
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CURL_INCLUDE_DIRS}
${MYSQL_INCLUDE_DIRS}
)
target_link_libraries(syncCommon ${CURL_LIBRARIES} ${MYSQL_LIBRARY})
sync/SyncProcessor/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(SyncProcessor VERSION 2.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS " -std=c++11 -Wall -O2 -w -g -O0 -fpermissive -pthread")
set(CMAKE_CXX_STANDARD_REQUIRED True)
file(GLOB project_SRCS src/*.cpp src/*.h)
find_package(CURL REQUIRED)
include_directories(src/ ../SyncCommon/src)
add_executable(syncProcessor ${project_SRCS})
target_include_directories(syncProcessor
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CURL_INCLUDE_DIRS}
)
target_link_libraries(syncProcessor syncCommon ${CURL_LIBRARIES})
Now I'm trying to debug SyncManager. Functions in SyncCommon can be executed step by step. But when it comes to functions in SyncManager, I got this error "single stepping until exit from function". I already updated gdb to newest version, but it still does not work.
Upvotes: 0
Views: 219
Reputation: 213375
Your sync/SyncCommon/CMakeLists.txt
has this:
set(CMAKE_CXX_FLAGS " -g -Wall -O2 -w -fpermissive -pthread")
Your sync/SyncManager/CMakeLists.txt
has this:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
file(GLOB project_SRCS src/*.cpp src/*.h)
You are using C
flags, despite having C++
sources. You should set both CMAKE_C_FLAGS
and CMAKE_CXX_FLAGS
, or just the latter if you don't have any plain-C
sources.
P.S. You should also get rid of -fpermissive
and -w
-- instead fix your sources so -fpermissive
is not necessary, and turn on -Wall
-- it's counter-productive to suppress compiler warnings -- you'll just spend longer debugging problems the compiler would have told you about.
Upvotes: 1