I hate cmake

This commit is contained in:
Frank Denis 2019-06-01 12:38:18 +02:00
parent 03ba8a6355
commit a27bd363b3
3 changed files with 22 additions and 301 deletions

View file

@ -36,12 +36,14 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(BUILD_STATIC_EXECUTABLES)
set(sodium_USE_STATIC_LIBS on)
set(LIBSODIUM_STATIC on)
if (NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS -static)
endif (NOT APPLE)
endif(BUILD_STATIC_EXECUTABLES)
find_package(sodium REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSODIUM REQUIRED libsodium)
add_executable(minisign
src/base64.c
@ -51,11 +53,22 @@ add_executable(minisign
target_include_directories(minisign PUBLIC ${sodium_INCLUDE_DIR})
if(BUILD_STATIC_EXECUTABLES)
target_link_libraries(minisign ${sodium_LIBRARY_RELEASE})
else(BUILD_STATIC_EXECUTABLES)
target_link_libraries(minisign ${sodium_LIBRARY_RELEASE})
endif(BUILD_STATIC_EXECUTABLES)
if(LIBSODIUM_STATIC)
target_compile_options(minisign PUBLIC ${LIBSODIUM_STATIC_CFLAGS} ${LIBSODIUM_CFLAGS_STATIC_OTHER})
target_link_libraries(minisign ${LIBSODIUM_STATIC_LDFLAGS} ${LIBSODIUM_STATIC_LDFLAGS_OTHER})
else(LIBSODIUM_STATIC)
target_compile_options(minisign PUBLIC ${LIBSODIUM_CFLAGS} ${LIBSODIUM_CFLAGS_OTHER})
target_link_libraries(minisign ${LIBSODIUM_LDFLAGS} ${LIBSODIUM_LDFLAGS_OTHER})
endif(LIBSODIUM_STATIC)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(minisign PUBLIC "-pthread")
endif(THREADS_HAVE_PTHREAD_ARG)
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(minisign "${CMAKE_THREAD_LIBS_INIT}")
endif(CMAKE_THREAD_LIBS_INIT)
if (DEFINED CMAKE_STRIP)
add_custom_command(TARGET minisign POST_BUILD