forked from l3af-project/l3afd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
35 lines (30 loc) · 1.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
cmake_minimum_required(VERSION 3.10)
project(l3afd)
add_custom_target(swagger ALL
DEPENDS ${CMAKE_SOURCE_DIR}/docs/docs.go
${CMAKE_SOURCE_DIR}/docs/swagger.json
${CMAKE_SOURCE_DIR}/docs/swagger.yaml)
add_custom_command(OUTPUT $ENV{GOPATH}/bin/swag.exe
COMMAND go install github.com/swaggo/swag/cmd/swag@latest
COMMAND go get -u github.com/swaggo/http-swagger
COMMAND go get -u github.com/alecthomas/template)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/docs/docs.go
${CMAKE_SOURCE_DIR}/docs/swagger.json
${CMAKE_SOURCE_DIR}/docs/swagger.yaml
DEPENDS ${CMAKE_SOURCE_DIR}/apis/configwatch.go
$ENV{GOPATH}/bin/swag.exe
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND "$ENV{GOPATH}/bin/swag.exe" init -d "./" -g "apis/configwatch.go")
add_custom_target(build ALL
DEPENDS ${CMAKE_SOURCE_DIR}/l3afd.exe)
if (${WIN32})
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/l3afd.exe
DEPENDS ${CMAKE_SOURCE_DIR}/main.go
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND go build -tags WINDOWS .)
else ()
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/l3afd.exe
DEPENDS ${CMAKE_SOURCE_DIR}/main.go
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND go build .)
endif ()