Consolidate Linux and OSX build

Use pkg-config to find the right include path and lib names.
This commit is contained in:
Howard Su 2020-10-23 10:53:48 +08:00
parent 0fe5af9816
commit 6262c64daa
2 changed files with 23 additions and 43 deletions

View File

@ -11,16 +11,10 @@ endif (MSVC)
add_definitions(-DSDRPP_IS_CORE)
# Main code
file(GLOB SRC "src/*.cpp")
file(GLOB GUI "src/gui/*.cpp")
file(GLOB MENUS "src/gui/menus/*.cpp")
file(GLOB DIALOGS "src/gui/dialogs/*.cpp")
file(GLOB SIGPATH "src/signal_path/*.cpp")
file(GLOB IMGUI "src/imgui/*.cpp")
file(GLOB DUKTAPE "src/duktape/*.c")
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
# Add code to dyn lib
add_library(sdrpp_core SHARED ${SRC} ${GUI} ${MENUS} ${DIALOGS} ${SIGPATH} ${IMGUI} ${DUKTAPE})
add_library(sdrpp_core SHARED ${SRC})
set_target_properties(sdrpp_core PROPERTIES PREFIX "")
# Include core headers
@ -61,29 +55,11 @@ if (MSVC)
target_link_libraries(sdrpp_core PUBLIC volk)
endif (MSVC)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(sdrpp_core PUBLIC pthread)
target_link_libraries(sdrpp_core PUBLIC GL)
target_link_libraries(sdrpp_core PUBLIC GLEW)
target_link_libraries(sdrpp_core PUBLIC glfw)
target_link_libraries(sdrpp_core PUBLIC fftw3)
target_link_libraries(sdrpp_core PUBLIC fftw3f)
target_link_libraries(sdrpp_core PUBLIC portaudio)
target_link_libraries(sdrpp_core PUBLIC X11)
target_link_libraries(sdrpp_core PUBLIC Xxf86vm)
target_link_libraries(sdrpp_core PUBLIC dl)
target_link_libraries(sdrpp_core PUBLIC stdc++fs)
target_link_libraries(sdrpp_core PUBLIC volk)
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
else()
find_package(PkgConfig)
find_package(OpenGL REQUIRED)
pkg_check_modules(GLEW REQUIRED GLEW)
pkg_check_modules(GLEW REQUIRED glew)
pkg_check_modules(FFTW3 REQUIRED fftw3f)
pkg_check_modules(VOLK REQUIRED volk)
pkg_check_modules(GLFW3 REQUIRED glfw3)
@ -114,8 +90,15 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
${PORTAUDIO_STATIC_LIBRARIES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(sdrpp_core PUBLIC stdc++fs)
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif ()
endif ()
set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE)

View File

@ -3,12 +3,6 @@ project(soapy)
if (MSVC)
set(CMAKE_CXX_FLAGS "-O2 /std:c++17")
# Lib path
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/lib/")
# Misc headers
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")
else()
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive")
endif (MSVC)
@ -19,15 +13,18 @@ add_library(soapy SHARED ${SRC})
target_link_libraries(soapy PRIVATE sdrpp_core)
set_target_properties(soapy PROPERTIES PREFIX "")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(PkgConfig)
find_package(OpenGL REQUIRED)
if (MSVC)
# Lib path
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/lib/")
pkg_check_modules(SOAPY REQUIRED soapysdr)
# Misc headers
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")
else (MSVC)
find_package(PkgConfig)
pkg_check_modules(SOAPY REQUIRED SoapySDR)
target_include_directories(soapy PUBLIC ${SOAPY_INCLUDE_DIRS})
target_link_directories(soapy PUBLIC ${SOAPY_LIBRARY_DIRS})
target_link_libraries(soapy PUBLIC ${SOAPY_LIBRARIES})
else ()
target_link_libraries(soapy PUBLIC SoapySDR)
endif ()
endif (MSVC)