Add options to build PiHelper for different contexts
This commit is contained in:
parent
96f6ac62dd
commit
8954da8bab
3 changed files with 78 additions and 27 deletions
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 3.15.5)
|
cmake_minimum_required (VERSION 3.15.5)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
set(PIHELPER_VERSION 0.1.0)
|
set(PIHELPER_VERSION 0.1.0)
|
||||||
|
|
||||||
project(
|
project(
|
||||||
|
@ -28,7 +26,3 @@ project(
|
||||||
|
|
||||||
add_subdirectory(PiHelper)
|
add_subdirectory(PiHelper)
|
||||||
|
|
||||||
install(TARGETS pihelper libpihelper)
|
|
||||||
|
|
||||||
install(FILES PiHelper/pihelper.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/pihelper")
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with PiHelper. If not, see <https://www.gnu.org/licenses/>.
|
# along with PiHelper. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(PIHELPER_SOURCES
|
set(PIHELPER_SOURCES
|
||||||
pihelper.c
|
pihelper.c
|
||||||
log.c
|
log.c
|
||||||
|
@ -22,18 +24,12 @@ set(PIHELPER_SOURCES
|
||||||
config.c
|
config.c
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(libpihelper
|
|
||||||
${PIHELPER_SOURCES}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(libpihelper PROPERTIES OUTPUT_NAME "libpihelper")
|
|
||||||
|
|
||||||
add_executable(pihelper
|
|
||||||
${PIHELPER_SOURCES}
|
|
||||||
cli.c
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(/usr/local/include)
|
include_directories(/usr/local/include)
|
||||||
|
find_library (
|
||||||
|
CURL
|
||||||
|
NAMES curl libcurl
|
||||||
|
HINTS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64
|
||||||
|
)
|
||||||
find_library (
|
find_library (
|
||||||
JSONC
|
JSONC
|
||||||
NAMES json-c libjson-c
|
NAMES json-c libjson-c
|
||||||
|
@ -50,6 +46,10 @@ find_library (
|
||||||
HINTS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64
|
HINTS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (NOT CURL)
|
||||||
|
message(SEND_ERROR "Did not find curl")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT JSONC)
|
if (NOT JSONC)
|
||||||
message(SEND_ERROR "Did not find json-c")
|
message(SEND_ERROR "Did not find json-c")
|
||||||
endif()
|
endif()
|
||||||
|
@ -62,15 +62,58 @@ if (NOT OPENSSL)
|
||||||
message(SEND_ERROR "Did not find OpenSSL")
|
message(SEND_ERROR "Did not find OpenSSL")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(libpihelper curl)
|
option(PIHELPER_STATIC "Build Pi-Helper as a static library" ON)
|
||||||
target_link_libraries(pihelper curl)
|
|
||||||
|
|
||||||
target_link_libraries(libpihelper ${JSONC})
|
if (PIHELPER_STATIC)
|
||||||
target_link_libraries(pihelper ${JSONC})
|
add_library(libpihelperstatic STATIC
|
||||||
|
${PIHELPER_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(libpihelper ${CRYPTO})
|
set_target_properties(libpihelperstatic PROPERTIES OUTPUT_NAME "pihelper")
|
||||||
target_link_libraries(pihelper ${CRYPTO})
|
|
||||||
|
|
||||||
target_link_libraries(libpihelper ${OPENSSL})
|
target_link_libraries(libpihelperstatic ${CURL})
|
||||||
target_link_libraries(pihelper ${OPENSSL})
|
target_link_libraries(libpihelperstatic ${JSONC})
|
||||||
|
target_link_libraries(libpihelperstatic ${CRYPTO})
|
||||||
|
target_link_libraries(libpihelperstatic ${OPENSSL})
|
||||||
|
|
||||||
|
install(TARGETS libpihelperstatic )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(PIHELPER_SHARED "Build Pi-Helper as a shared library" OFF)
|
||||||
|
|
||||||
|
if (PIHELPER_SHARED)
|
||||||
|
add_library(libpihelpershared SHARED
|
||||||
|
${PIHELPER_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(libpihelpershared PROPERTIES OUTPUT_NAME "pihelper")
|
||||||
|
|
||||||
|
target_link_libraries(libpihelpershared ${CURL})
|
||||||
|
target_link_libraries(libpihelpershared ${JSONC})
|
||||||
|
target_link_libraries(libpihelpershared ${CRYPTO})
|
||||||
|
target_link_libraries(libpihelpershared ${OPENSSL})
|
||||||
|
|
||||||
|
install(TARGETS libpihelpershared)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(PIHELPER_DEV "Install Pi-Helper header files for development" OFF)
|
||||||
|
if (PIHELPER_DEV)
|
||||||
|
install(FILES PiHelper/pihelper.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/pihelper")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(PIHELPER_EXECUTABLE "Build Pi-Helper as an executable" OFF)
|
||||||
|
|
||||||
|
if (PIHELPER_EXECUTABLE)
|
||||||
|
add_executable(pihelper
|
||||||
|
${PIHELPER_SOURCES}
|
||||||
|
cli.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(pihelper ${CURL})
|
||||||
|
target_link_libraries(pihelper ${JSONC})
|
||||||
|
target_link_libraries(pihelper ${CRYPTO})
|
||||||
|
target_link_libraries(pihelper ${OPENSSL})
|
||||||
|
|
||||||
|
install(TARGETS pihelper)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
18
README.md
18
README.md
|
@ -36,9 +36,23 @@ Once you have the dependencies installed, you can build the project with cmake:
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
|
|
||||||
If you'd like to install pihelper to your system, run the following after building:
|
By default, this will build a static library you can link to. If you'd like to build a shared library, use
|
||||||
|
this cmake command instead:
|
||||||
|
|
||||||
sudo make install # This is optional, and only needed if you want to install command line utility
|
cmake -DPIHELPER_SHARED=BOOL:ON ..
|
||||||
|
|
||||||
|
If you'd like to have the command line tool as well, you can use this:
|
||||||
|
|
||||||
|
cmake -DPIHELPER_EXECUTABLE=BOOL:ON ..
|
||||||
|
|
||||||
|
If you need the development headers on your system, you can run this:
|
||||||
|
|
||||||
|
cmake -DPIHELPER_DEV=BOOL:ON ..
|
||||||
|
|
||||||
|
Once you've run cmake with the desired options, you can install pihelper to your system by runnning the
|
||||||
|
following after building:
|
||||||
|
|
||||||
|
sudo make install
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue