-1

i can compile project with pure g++ command, but i can't do same with cmake. Sorry for dumb question. I just start to work with cmake and google won't give me any solutions.

This is working fine

g++ -static main.cpp -o test -Wl,-Bstatic -lresolv -lutil -lstdc++

But when i compile with cmake i receive such errors

undefined reference to `ns_initparse'
undefined reference to `ns_parserr'
undefined reference to `forkpty'

My cmake file

cmake_minimum_required(VERSION 3.16)
project(test)

set(CMAKE_CXX_STANDARD 11)

add_link_options("-static")
add_compile_options("-lresolv -lutil") #it's like this options won't set
add_executable(test Source/main.cpp)
SLI
  • 713
  • 11
  • 29

1 Answers1

1

Try linking additional libs with target_link_libraries. Defining sources per target is also fancy:

add_executable(test)

target_sources(test
    PRIVATE
    Source/main.cpp
    )

target_link_libraries(test
    PRIVATE
    -lresolv
    -lutil
    )

target_compile_options(test
    PRIVATE
    -Wl
    )
Quasar
  • 101
  • 2