Skip to content

Commit

Permalink
issue #46 Automate cacert.pem download in CMakeLists.txt
Browse files Browse the repository at this point in the history
Automated the download of `cacert.pem` in `CMakeLists.txt` using `file(DOWNLOAD ...)`, removing manual instructions from `SOURCE.md`. Cleaned up `CMakeLists.txt` by removing outdated comments and license information. Updated `configure_file` and `install` commands to use and include `cacert.pem`. Added `<fstream>` header in `ChatGPTIPAProvider.cpp` for file operations.
  • Loading branch information
schnelle committed Jan 13, 2025
1 parent 80425a2 commit 22d5cde
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
4 changes: 0 additions & 4 deletions source/SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ You will need
git clone [email protected]:w3c/voiceinteraction.git
```

### Download certificates

Download cacert.pem from [curl.haxx.se](https://curl.haxx.se/docs/caextract.html) and place it in the folder `source/w3cipa/w3cipachatgptipaprovider`.

### Project Structure

The source code is in the folder source/w3cipa
Expand Down
30 changes: 12 additions & 18 deletions source/w3cipa/w3cipachatgptipaprovider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
#
# IPA Reference Implementation: https://github.com/w3c/voiceinteraction
#
# Copyright (C) 2024 World Wide Web Consortium. All Rights Reserved.
#
# This work is distributed under the W3C Software and Document License [1]
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# [1] https://www.w3.org/Consortium/Legal/copyright-software
#

cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.22)

project(w3cipachatgptipaprovider LANGUAGES CXX)

Expand Down Expand Up @@ -43,18 +31,24 @@ target_link_libraries(${PROJECT_NAME} w3cipareferenceimplementation)
target_link_libraries(${PROJECT_NAME} w3cipaframework)
target_include_directories(${PROJECT_NAME} PUBLIC include)

#
# Download cacert.pem if it doesn't exist
set(CACERT_URL "https://curl.se/ca/cacert.pem")
set(CACERT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cacert.pem")

if(NOT EXISTS ${CACERT_FILE})
message(STATUS "Downloading cacert.pem from ${CACERT_URL}")
file(DOWNLOAD ${CACERT_URL} ${CACERT_FILE} SHOW_PROGRESS)
endif()

# Add configuration files
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ChatGPTIPAProvider.json
${PROJECT_CONFIG_DIR}/ChatGPTIPAProvider.json COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cacert.pem
configure_file(${CACERT_FILE}
${PROJECT_CONFIG_DIR}/cacert.pem COPYONLY)

#
# Installation
#
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ChatGPTIPAProvider.json DESTINATION config)
install(FILES ${CACERT_FILE} DESTINATION config)
install(TARGETS ${PROJECT_NAME} FILE_SET HEADERS)
install(DIRECTORY doc/ DESTINATION doc)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

#include <filesystem>
#include <fstream>

#include <curl/curl.h>
#include <log4cplus/loggingmacros.h>
Expand Down

0 comments on commit 22d5cde

Please sign in to comment.