Improve cmake list and link against built lib instead of existing lib to prevent linker errors
This commit is contained in:
parent
23dcf01dfe
commit
47c849cc98
|
@ -1,36 +1,47 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(microirc LANGUAGES C)
|
||||
|
||||
# NOTE: Do these seem too annoying? Try writing good code then.
|
||||
# Code that triggers these warnings will not be accepted unless it has a good reason to trigger them.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Werror -Wformat-overflow=2 -Wformat-security -Winit-self -Wstrict-overflow=2 -Wstringop-overflow=2 -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wparentheses -fanalyzer -fstack-protector")
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options(-Wall -Wextra -Werror -Wformat-overflow=2 -Wformat-security -Winit-self -Wstrict-overflow=2 -Wstringop-overflow=2 -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wparentheses -fanalyzer -fstack-check)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Weverything)
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
if ( BUILD_IRCV3 )
|
||||
add_definitions(-DUIRC_IRCV3)
|
||||
endif()
|
||||
if ( BUILD_TESTS )
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
message("IRCv3 capabilities are going to be built.")
|
||||
add_compile_definitions(UIRC_IRCV3)
|
||||
endif()
|
||||
|
||||
set(build_FILES
|
||||
src/assemblers.c
|
||||
src/misc.c
|
||||
src/tokenizers.c
|
||||
src/validators.c
|
||||
)
|
||||
|
||||
if ( BUILD_HELPERS )
|
||||
message("Helper functions are going to be built.")
|
||||
set(build_FILES ${build_FILES} src/helpers.c src/taghelpers.c)
|
||||
endif()
|
||||
|
||||
add_library(uirc SHARED ${build_FILES})
|
||||
set_property(TARGET uirc PROPERTY C_STANDARD 99)
|
||||
|
||||
# NOTE: Do these seem too annoying? Try writing good code then.
|
||||
# Code that triggers these warnings will not be accepted unless it has a good reason to trigger them.
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
|
||||
DESTINATION "include/uirc"
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
install(TARGETS uirc DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
if ( BUILD_TESTS )
|
||||
message("Tests are going to be built.")
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
find_library(UIRC_PATH NAMES uirc libuirc REQUIRED)
|
||||
|
||||
add_executable(tokenizer tokenizer.c)
|
||||
add_executable(overflow overflow.c)
|
||||
|
@ -10,14 +9,14 @@ add_executable(notrail notrail.c)
|
|||
add_executable(spacedargs spacedargs.c)
|
||||
add_executable(strtokmr strtokmr.c)
|
||||
|
||||
target_link_libraries(tokenizer ${UIRC_PATH})
|
||||
target_link_libraries(overflow ${UIRC_PATH})
|
||||
target_link_libraries(prefixassm ${UIRC_PATH})
|
||||
target_link_libraries(msgassm ${UIRC_PATH})
|
||||
target_link_libraries(numericmds ${UIRC_PATH})
|
||||
target_link_libraries(notrail ${UIRC_PATH})
|
||||
target_link_libraries(spacedargs ${UIRC_PATH})
|
||||
target_link_libraries(strtokmr ${UIRC_PATH})
|
||||
target_link_libraries(tokenizer uirc)
|
||||
target_link_libraries(overflow uirc)
|
||||
target_link_libraries(prefixassm uirc)
|
||||
target_link_libraries(msgassm uirc)
|
||||
target_link_libraries(numericmds uirc)
|
||||
target_link_libraries(notrail uirc)
|
||||
target_link_libraries(spacedargs uirc)
|
||||
target_link_libraries(strtokmr uirc)
|
||||
|
||||
add_test(NAME Tokenizer COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tokenizer)
|
||||
add_test(NAME Overflow COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/overflow)
|
||||
|
@ -35,10 +34,10 @@ if ( BUILD_HELPERS )
|
|||
add_executable(timestamp timestamp.c)
|
||||
endif()
|
||||
|
||||
target_link_libraries(tagtok ${UIRC_PATH})
|
||||
target_link_libraries(tagassm ${UIRC_PATH})
|
||||
target_link_libraries(tagtok uirc)
|
||||
target_link_libraries(tagassm uirc)
|
||||
if ( BUILD_HELPERS )
|
||||
target_link_libraries(timestamp ${UIRC_PATH})
|
||||
target_link_libraries(timestamp uirc)
|
||||
endif()
|
||||
|
||||
add_test(NAME TagParser COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tagtok)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#ifndef UIRC_IRCV3
|
||||
#define UIRC_IRCV3
|
||||
#endif
|
||||
#include "../include/uirc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#ifndef UIRC_IRCV3
|
||||
#define UIRC_IRCV3
|
||||
#endif
|
||||
#include "../include/uirc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
Reference in New Issue