Skip to content

Commit

Permalink
[WIP] drop wincompat/getopt, rely on vcpkg to provide getopt (litespe…
Browse files Browse the repository at this point in the history
…edtech#40)

* drop wincompat/getopt, rely on vcpkg to provide getopt

* update appveyor to use vcpkg

add getopt lookup to CMakeLists.txt

add getopt linkage to targets for windows
  • Loading branch information
TYoungSL authored Dec 15, 2021
1 parent 0b33c64 commit 948d3c7
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 1,089 deletions.
9 changes: 8 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
version: 1.0.{build}

image: Visual Studio 2017

cache:
- c:\tools\vcpkg\installed

before_build:
- cmake -DLSQPACK_TESTS=ON .
- vcpkg install getopt:x64-windows
- vcpkg integrate install
- cmake -DLSQPACK_TESTS=ON -DCMAKE_GENERATOR_PLATFORM=x64 -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DGETOPT_INCLUDE_DIR=c:/tools/vcpkg/installed/x64-windows/include -DGETOPT_LIB=c:/tools/vcpkg/installed/x64-windows/lib/getopt.lib .

build_script:
- cmake --build .
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ else()
)
endif()

IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
FIND_PATH(GETOPT_INCLUDE_DIR NAMES getopt.h)
IF (GETOPT_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${GETOPT_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "getopt.h was not found")
ENDIF()
FIND_LIBRARY(GETOPT_LIB getopt)
IF(GETOPT_LIB)
MESSAGE(STATUS "Found getopt: ${GETOPT_LIB}")
ELSE()
MESSAGE(STATUS "getopt not found")
ENDIF()
ENDIF()

IF(DEFINED LSXPACK_MAX_STRLEN)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSXPACK_MAX_STRLEN=${LSXPACK_MAX_STRLEN}")
ENDIF()
Expand Down
5 changes: 1 addition & 4 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ function(lsqpack_add_executable TARGET)

if(MSVC)
target_include_directories(${TARGET} PRIVATE ../wincompat)
target_sources(${TARGET} PRIVATE
../wincompat/getopt.c
../wincompat/getopt1.c
)
target_link_libraries(${TARGET} PRIVATE ${GETOPT_LIB})
else()
target_link_libraries(${TARGET} PRIVATE m)
endif()
Expand Down
2 changes: 1 addition & 1 deletion bin/interop-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include "getopt.h"
#include <getopt.h>
#else
#include <unistd.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion bin/interop-encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include "getopt.h"
#include <getopt.h>
#else
#include <unistd.h>
#endif
Expand Down
5 changes: 1 addition & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ function(lsqpack_add_test TARGET)

if(MSVC)
target_include_directories(test_${TARGET} PRIVATE ../wincompat)
target_sources(test_${TARGET} PRIVATE
../wincompat/getopt.c
../wincompat/getopt1.c
)
target_link_libraries(test_${TARGET} ${GETOPT_LIB})
else()
target_link_libraries(test_${TARGET} m)
endif()
Expand Down
2 changes: 1 addition & 1 deletion test/test_huff_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include "getopt.h"
#include <getopt.h>
#else
#include <unistd.h>
#endif
Expand Down
Loading

0 comments on commit 948d3c7

Please sign in to comment.