起因
处理
//file: public.h
#ifdef WIN32
#    include "os/windows/public.h"
#else
#    include "os/linux/public.h" 
#endif //WIN32
产生问题
使用的编译构建系统如何来识别这些编译哪个目录下的文件,在链接的时候如何选择库
不同的编译系统下的解决
直接Makefile
通过宏来区分
ifdef WIN32
    SOURCES += $(wildcard os/win/*.cpp)
else
    SOURCES += $(wildcard os/linux/*.cpp)
endif
cmake
cmake通过逻辑语句和预定义变量来判定
if(WIN32)
    aux_source_directory(os/win SOURCES)
else(APPLE)
    aux_source_directory(os/mac SOURCES)
else(UNIX)
    aux_source_directory(os/linux SOURCES)
endif(WIN)
qmake
qt的.pro文件支持直接以
!unix {
    SOURCES += comm.cpp
}win32:debug {
    TARGET = client_debug.exe
}win32 | macx {
    HEADERS += debug.h
}linux-g++ {
    CONFIGS += c++11}
                                                                                                                       --转自
