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

cmake not finding libacars-2 #44

Open
TanerH opened this issue May 25, 2020 · 3 comments
Open

cmake not finding libacars-2 #44

TanerH opened this issue May 25, 2020 · 3 comments

Comments

@TanerH
Copy link
Contributor

TanerH commented May 25, 2020

The CMakeLists.txt is only looking for libacars, and not libacars-2 (which is the latest from https://github.com/szpajder/libacars )

This diff will check for acars-2, first, and then acars, before giving up on that library.

(Forgive the indenting, please adjust as you'd like)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c619ab7..b86ea58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,13 +5,20 @@ add_compile_options(-Ofast -march=native )

 add_executable(vdlm2dec cJSON.c  crc.c  d8psk.c  label.c  main.c  outacars.c  out.c  outxid.c  rs.c  vdlm2.c  viterbi.c )

-find_library(LIBACARS acars)
-if(LIBACARS)
-message ( STATUS "Using libacars")
-add_definitions(-DHAVE_LIBACARS )
-target_link_libraries( vdlm2dec acars)
+find_library(LIBACARS2 acars-2)
+if(LIBACARS2)
+       message ( STATUS "Using libacars-2")
+       add_definitions(-DHAVE_LIBACARS )
+       target_link_libraries( vdlm2dec acars-2)
 else()
-message ( STATUS "Not using libacars")
+       find_library(LIBACARS acars)
+       if(LIBACARS)
+               message ( STATUS "Using libacars")
+               add_definitions(-DHAVE_LIBACARS )
+               target_link_libraries( vdlm2dec acars)
+       else()
+               message ( STATUS "Not using libacars (v1 or v2)")
+       endif()
 endif()

 option(rtl "Compiling for rtl sdr" )
@kevinelliott
Copy link

@TanerH Want to put this in a PR?

@kevinelliott
Copy link

@TanerH Ping... if you end up having a moment... or not if you don't think it's useful anymore :)

@cdschuett
Copy link

cdschuett commented Dec 23, 2020

The change suggested by @TanerH fixed the issue with cmake not finding the libacars library, but I got compile errors when the script was compiling outacars. It couldn't find the header files for the library.
I fixed it by adding:
if(LIBACARS2)
message ( STATUS "Using libacars-2")
add_definitions(-DHAVE_LIBACARS )
target_link_libraries( vdlm2dec acars-2)
target_include_directories( vdlm2dec PUBLIC "/usr/local/include/libacars-2")
else()
find_library(LIBACARS acars)
if(LIBACARS)
message ( STATUS "Using libacars")
add_definitions(-DHAVE_LIBACARS )
target_link_libraries( vdlm2dec acars)
target_include_directories( vdlm2dec PUBLIC "/usr/local/include/libacars")

There might be a better way to do this, but this worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants