Updates for linux build

Update CMakeLists.txt and #include <algorithm> in layer.cpp.