cMakeLists.txt - 项目是在调试模式还是发布模式下构建的?

时间:2017-10-23 07:48:50

标签: cmake release

我正在使用的项目中的头文件中定义了一个名为LOG(STR)的宏。它在#ifdef #endif

中定义
#ifdef LWM2M_WITH_LOGS
#include <inttypes.h>
#define LOG(STR) lwm2m_printf("[%s:%d] " STR "\r\n", __func__ , __LINE__)
#define LOG_ARG(FMT, ...) lwm2m_printf("[%s:%d] " FMT "\r\n", __func__ , __LINE__ , __VA_ARGS__)

该项目是使用cmake构建的。并且CMakeLists.txt文件位于下方。我想确定(1)编译期间是否包含此代码,以及(2)输出这些lwm2m_printf()语句的位置。

我真的没有在cmakelists.txt文件中看到任何暗示包含它的内容吗?除了最后一行set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:WITH_LOGS>)

项目是否配置为以调试或发布模式构建?

cmake_minimum_required (VERSION 3.0)

project (lwm2mclient)
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "9")
SET(VERSION_PATCH "1")
SET(VERSION "$(VERSION_MAJOR).(VERSION_MINOR).(VERSION_PATCH)")

option(DTLS "Enable DTLS" OFF)

# Compiler include
SET(CRADLE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../cradle-bsp/cradle-util/libcradle)

include(${CMAKE_CURRENT_LIST_DIR}/../../core/wakaama.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../shared/shared.cmake)

add_definitions(-DLWM2M_CLIENT_MODE -DLWM2M_BOOTSTRAP -DLWM2M_SUPPORT_JSON)
add_definitions(${SHARED_DEFINITIONS} ${WAKAAMA_DEFINITIONS})
add_definitions( -DDebug )
add_definitions( -DRelease )

include_directories (${WAKAAMA_SOURCES_DIR} ${SHARED_INCLUDE_DIRS} ${CRADLE_INCLUDE_DIR} )

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O0")


#message("CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}")
message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}")

if(NOT CMAKE_BUILD_TYPE) 
    set(CMAKE_BUILD_TYPE Debug)
endif(NOT CMAKE_BUILD_TYPE)

SET(SOURCES
    string_functions.c
    base64.c
    dut_functions.c
    lwm2mclient.c
    system_api.c
    object_security.c
    object_server.c
    object_device.c
    object_firmware.c
    object_location.c

    )

find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB_PKG glib-2.0)
message(Found glib-2.0)
include_directories(${GLIB_PKG_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} ${SOURCES} ${WAKAAMA_SOURCES} ${SHARED_SOURCES})

target_link_libraries(${PROJECT_NAME} pthread iniparser.a websockets jansson b64)

LINK_DIRECTORIES(/usr/local/lib /usr/lib/x86_64-linux-gnu )

# Add WITH_LOGS to debug variant
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:WITH_LOGS>)

0 个答案:

没有答案