diff --git a/CMakeLists.txt b/CMakeLists.txt index b23f89ad..3d2039c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,3 +85,19 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif () # cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64" + +# Default to /usr for CMAKE_INSTALL_PREFIX +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Default install prefix" FORCE) +endif() + +# Install directives +install(TARGETS sdrpp DESTINATION bin) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/root/res/bandplans DESTINATION share/sdrpp) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/root/res/colormaps DESTINATION share/sdrpp) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/root/res/fonts DESTINATION share/sdrpp) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/root/res/icons DESTINATION share/sdrpp) + +# Create uninstall target +configure_file(${CMAKE_SOURCE_DIR}/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) +add_custom_target(uninstall ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) \ No newline at end of file diff --git a/airspy_source/CMakeLists.txt b/airspy_source/CMakeLists.txt index 605c70e7..6306e9db 100644 --- a/airspy_source/CMakeLists.txt +++ b/airspy_source/CMakeLists.txt @@ -28,4 +28,7 @@ else (MSVC) target_include_directories(airspy_source PUBLIC ${LIBAIRSPYHF_INCLUDE_DIRS}) target_link_directories(airspy_source PUBLIC ${LIBAIRSPYHF_LIBRARY_DIRS}) target_link_libraries(airspy_source PUBLIC ${LIBAIRSPYHF_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS airspy_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/airspyhf_source/CMakeLists.txt b/airspyhf_source/CMakeLists.txt index e411f7b1..413b16d0 100644 --- a/airspyhf_source/CMakeLists.txt +++ b/airspyhf_source/CMakeLists.txt @@ -28,4 +28,7 @@ else (MSVC) target_include_directories(airspyhf_source PUBLIC ${LIBAIRSPYHF_INCLUDE_DIRS}) target_link_directories(airspyhf_source PUBLIC ${LIBAIRSPYHF_LIBRARY_DIRS}) target_link_libraries(airspyhf_source PUBLIC ${LIBAIRSPYHF_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS airspyhf_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/audio_sink/CMakeLists.txt b/audio_sink/CMakeLists.txt index 5f556869..2dc49670 100644 --- a/audio_sink/CMakeLists.txt +++ b/audio_sink/CMakeLists.txt @@ -29,4 +29,7 @@ else (MSVC) target_link_libraries(sdrpp_core PUBLIC ${PORTAUDIO_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS audio_sink DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 00000000..c0fa3e63 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,32 @@ +# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F + +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + IF(EXISTS "$ENV{DESTDIR}${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) + ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) + ELSE(EXISTS "$ENV{DESTDIR}${file}") + MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + ENDIF(EXISTS "$ENV{DESTDIR}${file}") +ENDFOREACH(file) \ No newline at end of file diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index d57e9e63..2a50f142 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -10,6 +10,9 @@ else() endif (MSVC) add_definitions(-DSDRPP_IS_CORE) +# Set the install prefix +add_compile_definitions(INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") + # Main code file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c") @@ -88,3 +91,6 @@ endif () set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE) # cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64" + +# Install directives +install(TARGETS sdrpp_core DESTINATION lib) \ No newline at end of file diff --git a/core/src/core.cpp b/core/src/core.cpp index c0051268..7553edaf 100644 --- a/core/src/core.cpp +++ b/core/src/core.cpp @@ -28,6 +28,10 @@ #include #endif +#ifndef INSTALL_PREFIX + #define INSTALL_PREFIX "/usr" +#endif + namespace core { ConfigManager configManager; ScriptManager scriptManager; @@ -146,8 +150,8 @@ int sdrpp_main(int argc, char *argv[]) { defConfig["modulesDirectory"] = "./modules"; defConfig["resourcesDirectory"] = "./res"; #else - defConfig["modulesDirectory"] = "/usr/lib/sdrpp/plugins"; - defConfig["resourcesDirectory"] = "/usr/share/sdrpp"; + defConfig["modulesDirectory"] = (std::string)INSTALL_PREFIX + "/lib/sdrpp/plugins"; + defConfig["resourcesDirectory"] = (std::string)INSTALL_PREFIX + "/share/sdrpp"; #endif // Load config diff --git a/file_source/CMakeLists.txt b/file_source/CMakeLists.txt index a74403db..303b2b5f 100644 --- a/file_source/CMakeLists.txt +++ b/file_source/CMakeLists.txt @@ -13,4 +13,7 @@ file(GLOB SRC "src/*.cpp") add_library(file_source SHARED ${SRC}) target_link_libraries(file_source PRIVATE sdrpp_core) -set_target_properties(file_source PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(file_source PROPERTIES PREFIX "") + +# Install directives +install(TARGETS file_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/hackrf_source/CMakeLists.txt b/hackrf_source/CMakeLists.txt index 2207f7e1..5a934dda 100644 --- a/hackrf_source/CMakeLists.txt +++ b/hackrf_source/CMakeLists.txt @@ -28,4 +28,7 @@ else (MSVC) target_include_directories(hackrf_source PUBLIC ${LIBHACKRF_INCLUDE_DIRS}) target_link_directories(hackrf_source PUBLIC ${LIBHACKRF_LIBRARY_DIRS}) target_link_libraries(hackrf_source PUBLIC ${LIBHACKRF_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS hackrf_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/plutosdr_source/CMakeLists.txt b/plutosdr_source/CMakeLists.txt index 00c9cfcb..ed7b8e3d 100644 --- a/plutosdr_source/CMakeLists.txt +++ b/plutosdr_source/CMakeLists.txt @@ -35,4 +35,7 @@ else (MSVC) target_include_directories(plutosdr_source PUBLIC ${LIBAD9361_INCLUDE_DIRS}) target_link_directories(plutosdr_source PUBLIC ${LIBAD9361_LIBRARY_DIRS}) target_link_libraries(plutosdr_source PUBLIC ${LIBAD9361_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS plutosdr_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/radio/CMakeLists.txt b/radio/CMakeLists.txt index 9070abfb..6e9a8196 100644 --- a/radio/CMakeLists.txt +++ b/radio/CMakeLists.txt @@ -13,4 +13,7 @@ include_directories("src/") add_library(radio SHARED ${SRC}) target_link_libraries(radio PRIVATE sdrpp_core) -set_target_properties(radio PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(radio PROPERTIES PREFIX "") + +# Install directives +install(TARGETS radio DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/recorder/CMakeLists.txt b/recorder/CMakeLists.txt index 9b4d2e20..979c6887 100644 --- a/recorder/CMakeLists.txt +++ b/recorder/CMakeLists.txt @@ -13,4 +13,7 @@ include_directories("src/") add_library(recorder SHARED ${SRC}) target_link_libraries(recorder PRIVATE sdrpp_core) -set_target_properties(recorder PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(recorder PROPERTIES PREFIX "") + +# Install directives +install(TARGETS recorder DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/rtl_tcp_source/CMakeLists.txt b/rtl_tcp_source/CMakeLists.txt index b7b5dc5f..8ea2d295 100644 --- a/rtl_tcp_source/CMakeLists.txt +++ b/rtl_tcp_source/CMakeLists.txt @@ -17,4 +17,7 @@ set_target_properties(rtl_tcp_source PROPERTIES PREFIX "") if(WIN32) target_link_libraries(rtl_tcp_source PRIVATE wsock32 ws2_32) -endif() \ No newline at end of file +endif() + +# Install directives +install(TARGETS rtl_tcp_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/rx888_source/CMakeLists.txt b/rx888_source/CMakeLists.txt index c017217e..f7f0293d 100644 --- a/rx888_source/CMakeLists.txt +++ b/rx888_source/CMakeLists.txt @@ -14,4 +14,7 @@ file(GLOB CYAPI "src/CyAPI/*.cpp") add_library(rx888_source SHARED ${SRC} ${CYAPI}) target_link_libraries(rx888_source PRIVATE sdrpp_core) -set_target_properties(rx888_source PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(rx888_source PROPERTIES PREFIX "") + +# Install directives +install(TARGETS rx888_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/sdrplay_source/CMakeLists.txt b/sdrplay_source/CMakeLists.txt index be7e9017..ed9c6393 100644 --- a/sdrplay_source/CMakeLists.txt +++ b/sdrplay_source/CMakeLists.txt @@ -29,4 +29,7 @@ else (MSVC) target_include_directories(sdrplay_source PUBLIC ${LIBSDRPLAY_INCLUDE_DIRS}) target_link_directories(sdrplay_source PUBLIC ${LIBSDRPLAY_LIBRARY_DIRS}) target_link_libraries(sdrplay_source PUBLIC ${LIBSDRPLAY_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS sdrplay_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/soapy_source/CMakeLists.txt b/soapy_source/CMakeLists.txt index d7ae77b2..96e47d57 100644 --- a/soapy_source/CMakeLists.txt +++ b/soapy_source/CMakeLists.txt @@ -29,4 +29,7 @@ else (MSVC) target_include_directories(soapy_source PUBLIC ${SOAPY_INCLUDE_DIRS}) target_link_directories(soapy_source PUBLIC ${SOAPY_LIBRARY_DIRS}) target_link_libraries(soapy_source PUBLIC ${SOAPY_LIBRARIES}) -endif (MSVC) \ No newline at end of file +endif (MSVC) + +# Install directives +install(TARGETS soapy_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file diff --git a/spyserver_source/CMakeLists.txt b/spyserver_source/CMakeLists.txt index 48a43217..a9a0e623 100644 --- a/spyserver_source/CMakeLists.txt +++ b/spyserver_source/CMakeLists.txt @@ -17,4 +17,7 @@ set_target_properties(spyserver_source PROPERTIES PREFIX "") if(WIN32) target_link_libraries(spyserver_source PRIVATE wsock32 ws2_32) -endif() \ No newline at end of file +endif() + +# Install directives +install(TARGETS spyserver_source DESTINATION lib/sdrpp/plugins) \ No newline at end of file