How can I generate a cmakelist equivalent to my Makefile

Asked

Viewed 32 times

0

I have a Makefile that is like this and works for what I want.

all:
    gcc -c curl_code.c -lcurl
    gcc -o Sete_Cliques curl_code.o main.c -lcurl
    gcc -o Sete_Cliques_Serial curl_code.o sete_cliques_serial.c -lcurl
    gcc -o Sete_Cliques_Threads curl_code.o sete_cliques_threads.c -lcurl

serial:
    gcc -c curl_code.c -lcurl
    gcc -o Sete_Cliques_Serial curl_code.o sete_cliques_serial.c -lcurl

threads:
    gcc -c curl_code.c -lcurl
    gcc -o Sete_Cliques_Threads curl_code.o sete_cliques_threads.c -lcurl

clean:
    rm curl_code.o
    rm Sete_Cliques

However, I am using the Clion IDE and I am not able to compile, follow the current Cmakelists.txt file, I need to generate an equivalent to the above Makefile

project(t3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lcurl")

add_executable(curl_code.o curl_code.c)
add_executable(Sete_Cliques curl_code.o main.c)
add_executable(Sete_Cliques_Serial curl_code.o sete_cliques_serial.c)
add_executable(Sete_Cliques_Threads curl_code.o sete_cliques_threads.c)

Any ideas? Thank you.

Gives error when finding references to the code that is in curl_code. h

Scanning dependencies of target Sete_Cliques
[ 50%] Linking C executable Sete_Cliques
CMakeFiles/Sete_Cliques.dir/main.c.o: In function `main':
/home/joao/main.c:29: undefined reference to `curl_global_cleanup'

1 answer

0

The Cmakelists.txt you showed does not match the Makefile...

I don’t know how Clion works with cmake, but a Cmakelists.equivalent to Makefile would be something like this (I left only the essentials):

project(t3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lcurl")
add_executable(Sete_Cliques Sete_Cliques.c curl_code.cpp curl_code.h)

I don’t even know if it will work, it depends on your environment, but the Cmakelists.txt equivalent of Makefile is this one

  • Hi buddy, it didn’t work. I edited the question and added the build error. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.