Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system/artable3: add cmake build support #1848

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- name: Check Pull Request
run: |
echo "::add-matcher::nuttx/.github/nxstyle.json"
pip install cmake-format
cd apps
commits="${{ github.event.pull_request.base.sha }}..HEAD"
git log --oneline $commits
Expand Down
91 changes: 91 additions & 0 deletions system/argtable3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ##############################################################################
# apps/system/argtable3/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

if(CONFIG_SYSTEM_ARGTABLE3)
nuttx_add_library(argtable3)

if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/argtable3/.git)

if(NOT CONFIG_SYSTEM_ARGTABLE3_URL)
set(CONFIG_SYSTEM_ARGTABLE3_URL
"https://github.com/argtable/argtable3/archive")
endif()

if(NOT CONFIG_SYSTEM_ARGTABLE3_VERSION)
set(CONFIG_SYSTEM_ARGTABLE3_VERSION "3.2.0.7402e6e")
endif()

FetchContent_Declare(
argtable3
DOWNLOAD_NAME "v${CONFIG_SYSTEM_ARGTABLE3_VERSION}.tar.gz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "${CONFIG_SYSTEM_ARGTABLE3_URL}/v${CONFIG_SYSTEM_ARGTABLE3_VERSION}.tar.gz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/argtable3
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/system/argtable3/argtable3
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

FetchContent_GetProperties(argtable3)

if(NOT argtable3_POPULATED)
FetchContent_Populate(argtable3)
endif()
endif()

set(SRCS)
file(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/argtable3/src/*.c)

if(CONFIG_SYSTEM_ARGTABLE3_TEST)
file(GLOB testsrcs ${CMAKE_CURRENT_LIST_DIR}/argtable3/tests/*.c)

nuttx_add_application(
NAME
${CONFIG_SYSTEM_ARGTABLE3_TEST_PROGNAME}
SRCS
${CMAKE_CURRENT_LIST_DIR}/argtable3/tests/testall.c
${testsrcs}
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/argtable3/src
STACKSIZE
${CONFIG_SYSTEM_ARGTABLE3_TEST_STACKSIZE}
PRIORITY
${CONFIG_SYSTEM_ARGTABLE3_TEST_PRIORITY})
endif()

target_sources(argtable3 PRIVATE ${SRCS})

if(NOT EXISTS ${CMAKE_BINARY_DIR}/apps/include/argtable3.h)
file(CREATE_LINK ${CMAKE_CURRENT_LIST_DIR}/argtable3/src/argtable3.h
${CMAKE_BINARY_DIR}/apps/include/argtable3.h SYMBOLIC)
endif()

target_compile_options(argtable3 PRIVATE -DARG_REPLACE_GETOPT=0)

endif()
Loading