diff options
author | YohanPipereau <ypiperea@cisco.com> | 2019-03-12 14:15:26 +0100 |
---|---|---|
committer | Hongjun Ni <hongjun.ni@intel.com> | 2019-03-18 00:51:36 +0000 |
commit | d7680154981c54989bcbcab81173791dc1805512 (patch) | |
tree | 5a1e807c0cb91d478eca43d0f673daa4006fa124 /src/plugins | |
parent | f8118bf32a5e5276f796c3f03095c2ee1a41423a (diff) |
Fix Cmake build environment and harden Warnings
-Remove unused sweetcomb CmakeList.txt Warnings
-Add more Warnings to plugins, scvpp and gNMI Cmake projects
-Remove unused/useless Cmake options in CmakeList files & add comments
-Improve gNMI CMakeList.txt and make it independant of a gRPC cmake build for
later package integration.
-Add FindGRPC.cmake
-Remove the use of CXX17 variant and use a dedicated Cmake module for
gRPC
Change-Id: Iafa3c031d12802e8d8c914cbce6b119c2a5c4800
Signed-off-by: Yohan Pipereau <ypiperea@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/CMakeLists.txt | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index e8b69e7..72a87bd 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -12,24 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. - cmake_minimum_required(VERSION 2.8) project(sysrepo-vpp-plugins) -# set compiler option -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) -set(CMAKE_C_FLAGS "-Wall -std=gnu99") -set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2") -set(CMAKE_C_FLAGS_DEBUG "-g -O0") -set (CMAKE_INSTALL_LIBDIR "/usr/lib") +# DEPENDENCIES +############## -# Cmake find modules +# Cmake find modules directory list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") -find_package(VPP) -find_package(PkgConfig) -pkg_check_modules(SYSREPO REQUIRED libsysrepo) -pkg_check_modules(SCVPP REQUIRED libscvpp) +# check for required packages +find_package(VPP) #use FindVPP.cmake +find_package(PkgConfig) #official cmake module +pkg_check_modules(SYSREPO REQUIRED libsysrepo) #PkgConfig cmake module maccro +pkg_check_modules(SCVPP REQUIRED libscvpp) #PkgConfig cmake module maccro # get sysrepo plugins directory from pkgconfig if (NOT SR_PLUGINS_DIR) @@ -42,6 +38,19 @@ if (NOT SR_PLUGINS_DIR) message(FATAL_ERROR "Cannot get sysrepo plugins directory due to missing pkg-config, set SR_PLUGINS_DIR manually.") endif() +# COMPILER & LINKER +################### + +# Generate a compile_commands.json with compile options +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) + +# set compiler and linker flags +set(RIGOROUS_C_FLAGS "-Wlogical-op -Wformat=2") +set(CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99 ${RIGOROUS_C_FLAGS}") +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -std=gnu99 -g -O0 ${RIGOROUS_C_FLAGS}") +#NDEBUG to skip assert checks +set(CMAKE_C_FLAGS_RELEASE "-Wall -Wextra -std=gnu99 -DNDEBUG -O2 ${RIGOROUS_C_FLAGS}") + # plugins sources set(PLUGINS_SOURCES sc_plugins.c @@ -56,5 +65,8 @@ set(PLUGINS_SOURCES add_library(vpp-plugins SHARED ${PLUGINS_SOURCES}) target_link_libraries(vpp-plugins ${SYSREPO_LIBRARIES} ${SCVPP_LIBRARIES}) +# INSTALL +######### + # install the plugin into plugins dir install(TARGETS vpp-plugins DESTINATION ${SR_PLUGINS_DIR}) |