Use more modern CMake syntax.

This commit is contained in:
Nicholas J. Kain 2018-10-26 13:07:05 -04:00
parent 56b6ae2cd3
commit c5a1edd5f6
2 changed files with 32 additions and 16 deletions

View File

@ -1,6 +1,9 @@
project (ndhc) cmake_minimum_required(VERSION 3.3)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_minimum_required (VERSION 2.6) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.12)
endif()
#################################### ####################################
@ -77,8 +80,8 @@ ENDMACRO(COMPARE_VERSION_STRINGS)
#################################### ####################################
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-overflow -pedantic -Wall -Wextra -Wimplicit-fallthrough=0 -Wformat=2 -Wformat-nonliteral -Wformat-security -Wshadow -Wpointer-arith -Wmissing-prototypes -Wunused-const-variable=0 -Wsign-conversion -D_GNU_SOURCE -DNK_USE_CAPABILITY") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-overflow -pedantic -Wall -Wextra -Wimplicit-fallthrough=0 -Wformat=2 -Wformat-nonliteral -Wformat-security -Wshadow -Wpointer-arith -Wmissing-prototypes -Wunused-const-variable=0 -Wcast-qual -Wsign-conversion -D_GNU_SOURCE -DNK_USE_CAPABILITY -Wno-discarded-qualifiers")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-overflow -pedantic -Wall -Wextra -Wimplicit-fallthrough=0 -Wformat-security -Wshadow -Wpointer-arith -Wmissing-prototypes -Wunused-const-variable=0 -Wsign-conversion -D_GNU_SOURCE -DNK_USE_CAPABILITY") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -fno-strict-overflow -fno-rtti -pedantic -Wall -Wextra -Wimplicit-fallthrough=0 -Wformat-security -Wshadow -Wpointer-arith -Wmissing-prototypes -Wunused-const-variable=0 -Wcast-qual -Wsign-conversion -D_GNU_SOURCE -DNK_USE_CAPABILITY")
if (WIN32) if (WIN32)
set(OSNAME "Win32") set(OSNAME "Win32")
@ -134,7 +137,5 @@ else()
set(MACHINENAME $ENV{CROSSCOMPILE_MACHINENAME}) set(MACHINENAME $ENV{CROSSCOMPILE_MACHINENAME})
endif() endif()
include_directories("${PROJECT_SOURCE_DIR}/ncmlib")
add_subdirectory(ncmlib) add_subdirectory(ncmlib)
add_subdirectory(src) add_subdirectory(src)

View File

@ -1,8 +1,4 @@
project (ndhc) project (ndhc DESCRIPTION "dhcp4 client" LANGUAGES C)
cmake_minimum_required (VERSION 2.6)
include_directories("${PROJECT_SOURCE_DIR}")
set(RAGEL_IFCHD_PARSE ${CMAKE_CURRENT_BINARY_DIR}/ifchd-parse.c) set(RAGEL_IFCHD_PARSE ${CMAKE_CURRENT_BINARY_DIR}/ifchd-parse.c)
set(RAGEL_CFG_PARSE ${CMAKE_CURRENT_BINARY_DIR}/cfg.c) set(RAGEL_CFG_PARSE ${CMAKE_CURRENT_BINARY_DIR}/cfg.c)
@ -25,7 +21,26 @@ add_custom_command(
VERBATIM VERBATIM
) )
file(GLOB NDHC_SRCS "*.c") add_executable(ndhc ${RAGEL_CFG_PARSE} ${RAGEL_IFCHD_PARSE})
target_sources(ndhc PRIVATE
add_executable(ndhc ${RAGEL_CFG_PARSE} ${RAGEL_IFCHD_PARSE} ${NDHC_SRCS}) "arp.c"
target_link_libraries(ndhc ncmlib) "ifchd.c"
"netlink.c"
"sockd.c"
"dhcp.c"
"ifset.c"
"nl.c"
"state.c"
"duiaid.c"
"leasefile.c"
"options.c"
"sys.c"
"ifchange.c"
"ndhc.c"
"rfkill.c"
)
target_include_directories(ndhc PRIVATE
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/../ncmlib"
)
target_link_libraries(ndhc PUBLIC ncmlib)