user6683825
user6683825

Reputation:

Link more than one file to executable

How can I link more than one file(test) to an executable?

I have this code:

set(TEST_EXE_NAME Test)
add_executable(${TEST_EXE_NAME} t1.cc)
add_executable(${TEST_EXE_NAME} t2.cc)
add_test(Test ${TEST_EXE_NAME})

This of course doesn't compile and I understand why. But is there a way to put both tests into one executable?

Upvotes: 0

Views: 208

Answers (2)

user7554810
user7554810

Reputation:

Just repeat it.

set(TEST_EXE_NAME Test)
add_executable(${TEST_EXE_NAME} t1.cc)
add_test(Test ${TEST_EXE_NAME})
set(TEST_EXE_NAME Test1)
add_executable(${TEST_EXE_NAME} t2.cc)
add_test(Test1 ${TEST_EXE_NAME})

Since you're testing this way the names can be more descriptive for each executable anyway.

Upvotes: 0

Cris Luengo
Cris Luengo

Reputation: 60494

You can give multiple source file names to the add_executable command:

add_executable(${TEST_EXE_NAME} t1.cc t2.cc)

Upvotes: 1

Related Questions