Add libdl and pthread to CMakeLists.txt