This might be a really dumb question. I'm using my CMakeLists.txt
which is declare source files in this way(I know it isn't a good practice):
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src DIR_SRC)
add_executable(hello "${DIR_SRC}")
After watch this speaking. I know that maybe I should not use include_directories
. But will it be lengthy and unreadable if I specify all source files manually when I call add_executable
?
BTW, if I have some classes need to call different API on different platform. Should I use
if (WIN32)
add_executable(hello SomeClassWin32.cpp SomeClass.h)
elseif (UNIX)
add_executable(hello SomeClassLinux.cpp SomeClass.h)
endif ()
or just use #ifdef
.
Any help will be really appreciated.