Move getopt out of the frontend, because it's used in the backend's test, too

This commit is contained in:
Schaich 2021-03-30 19:00:24 +09:00
parent 779a318c93
commit 88bbeb862b
7 changed files with 19 additions and 8 deletions

View file

@ -29,6 +29,7 @@ option(ZINT_USE_QT "Build with QT support" ON)
include(SetPaths.cmake)
include(CheckCXXCompilerFlag)
include(CheckFunctionExists)
check_cxx_compiler_flag("-Wall" CXX_COMPILER_FLAG_WALL)
if(CXX_COMPILER_FLAG_WALL)
@ -89,6 +90,11 @@ IF(APPLE)
ENDIF (UNIVERSAL)
ENDIF(APPLE)
check_function_exists(getopt HAVE_GETOPT)
if(NOT HAVE_GETOPT)
add_subdirectory(getopt)
endif(NOT HAVE_GETOPT)
add_subdirectory(backend)
add_subdirectory(frontend)

View file

@ -28,11 +28,17 @@ set(testcommon_SRCS testcommon.c testcommon.h)
add_library(testcommon ${testcommon_SRCS})
target_link_libraries(testcommon zint)
target_include_directories(testcommon PUBLIC ${zint_backend_tests_SOURCE_DIR})
if(NOT HAVE_GETOPT)
target_link_libraries(testcommon zint_bundled_getopt)
endif()
if(ZINT_STATIC)
add_library(testcommon-static ${testcommon_SRCS})
target_link_libraries(testcommon-static zint-static)
target_include_directories(testcommon-static PUBLIC ${zint_backend_tests_SOURCE_DIR})
if(NOT HAVE_GETOPT)
target_link_libraries(testcommon-static zint_bundled_getopt)
endif()
endif()
zint_add_test(2of5 test_2of5)

View file

@ -2,16 +2,8 @@
project(zint_frontend)
include(CheckFunctionExists)
check_function_exists(getopt HAVE_GETOPT)
set(zint_frontend_SRCS main.c)
if(NOT HAVE_GETOPT)
set(zint_frontend_SRCS ${zint_frontend_SRCS} getopt.c getopt1.c)
endif(NOT HAVE_GETOPT)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend")
add_executable(zint_frontend ${zint_frontend_SRCS})
@ -19,6 +11,9 @@ add_executable(zint_frontend ${zint_frontend_SRCS})
set_target_properties(zint_frontend PROPERTIES OUTPUT_NAME "zint")
target_link_libraries(zint_frontend zint)
if(NOT HAVE_GETOPT)
target_link_libraries(zint_frontend zint_bundled_getopt)
endif(NOT HAVE_GETOPT)
install(TARGETS zint_frontend DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)

4
getopt/CMakeLists.txt Normal file
View file

@ -0,0 +1,4 @@
project(zint_bundled_getopt)
add_library(zint_bundled_getopt STATIC getopt.c getopt1.c)
target_include_directories(zint_bundled_getopt PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})