Rearrange source layout so that lossmin builds in two ways

lossmin now builds stand-alone using the CMake file in the top-level
lossmin directory (or the Python script lossmin.py) and also
as part of the Cobalt build which includes the CMake file in
the second-level directory lossmin/lossmin. The source files
in lossmin refer to the lossmin header files via paths that
start with "lossmin". That is why we added an additional
directory layer.

Change-Id: Idb7ec11257751e008970a7f905d9eb6fd555bca3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f458476..c26dece 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,19 +3,31 @@
 # found in the LICENSE file.
 cmake_minimum_required (VERSION 2.8.10)
 
+# The only way we found to override the compiler is setting these variables
+# prior to the project definition.  Otherwise enable_language() sets these
+# variables and gcc will be picked up instead.  Also, new versions of cmake will
+# complain if one compiler is first set (say to gcc via enable_language), and
+# then we later switch it to (say) clang.
+SET (CMAKE_C_COMPILER "clang")
+SET (CMAKE_CXX_COMPILER "clang++")
+
 project(lossmin)
 
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
+SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -std=c++11 -stdlib=libstdc++ -fcolor-diagnostics")
 
 enable_language(C)
 enable_language(CXX)
 
-include_directories(..)
+include_directories(${CMAKE_SOURCE_DIR})
+
+# NOTE: Lossmin depends on eigen. We assume that eigen can be found at
+# ../../third_party/eigen.
+include_directories(${CMAKE_SOURCE_DIR}/../..)
+
+add_subdirectory(lossmin)
 
 add_executable(sample sample.cc)
 target_link_libraries(sample
-                      loss_functions
-                      minimizers)
+                      lossmin_loss_functions
+                      lossmin_minimizers)
 
-add_subdirectory(losses)
-add_subdirectory(minimizers)
diff --git a/lossmin/CMakeLists.txt b/lossmin/CMakeLists.txt
new file mode 100644
index 0000000..5e7c071
--- /dev/null
+++ b/lossmin/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright 2017 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
+
+add_subdirectory(losses)
+add_subdirectory(minimizers)
diff --git a/eigen-types.h b/lossmin/eigen-types.h
similarity index 100%
rename from eigen-types.h
rename to lossmin/eigen-types.h
diff --git a/losses/CMakeLists.txt b/lossmin/losses/CMakeLists.txt
similarity index 86%
rename from losses/CMakeLists.txt
rename to lossmin/losses/CMakeLists.txt
index 46ae888..734b730 100644
--- a/losses/CMakeLists.txt
+++ b/lossmin/losses/CMakeLists.txt
@@ -2,6 +2,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-add_library(loss_functions
+add_library(lossmin_loss_functions
             loss-function.cc
             inner-product-loss-function.cc)
diff --git a/losses/inner-product-loss-function.cc b/lossmin/losses/inner-product-loss-function.cc
similarity index 100%
rename from losses/inner-product-loss-function.cc
rename to lossmin/losses/inner-product-loss-function.cc
diff --git a/losses/inner-product-loss-function.h b/lossmin/losses/inner-product-loss-function.h
similarity index 100%
rename from losses/inner-product-loss-function.h
rename to lossmin/losses/inner-product-loss-function.h
diff --git a/losses/loss-function.cc b/lossmin/losses/loss-function.cc
similarity index 100%
rename from losses/loss-function.cc
rename to lossmin/losses/loss-function.cc
diff --git a/losses/loss-function.h b/lossmin/losses/loss-function.h
similarity index 100%
rename from losses/loss-function.h
rename to lossmin/losses/loss-function.h
diff --git a/minimizers/CMakeLists.txt b/lossmin/minimizers/CMakeLists.txt
similarity index 89%
rename from minimizers/CMakeLists.txt
rename to lossmin/minimizers/CMakeLists.txt
index 41b5871..80f75fc 100644
--- a/minimizers/CMakeLists.txt
+++ b/lossmin/minimizers/CMakeLists.txt
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-add_library(minimizers
+add_library(lossmin_minimizers
             gradient-evaluator.cc
             loss-minimizer.cc
             parallel-boosting-with-momentum.cc)
diff --git a/minimizers/gradient-evaluator.cc b/lossmin/minimizers/gradient-evaluator.cc
similarity index 100%
rename from minimizers/gradient-evaluator.cc
rename to lossmin/minimizers/gradient-evaluator.cc
diff --git a/minimizers/gradient-evaluator.h b/lossmin/minimizers/gradient-evaluator.h
similarity index 100%
rename from minimizers/gradient-evaluator.h
rename to lossmin/minimizers/gradient-evaluator.h
diff --git a/minimizers/loss-minimizer.cc b/lossmin/minimizers/loss-minimizer.cc
similarity index 100%
rename from minimizers/loss-minimizer.cc
rename to lossmin/minimizers/loss-minimizer.cc
diff --git a/minimizers/loss-minimizer.h b/lossmin/minimizers/loss-minimizer.h
similarity index 100%
rename from minimizers/loss-minimizer.h
rename to lossmin/minimizers/loss-minimizer.h
diff --git a/minimizers/parallel-boosting-with-momentum.cc b/lossmin/minimizers/parallel-boosting-with-momentum.cc
similarity index 100%
rename from minimizers/parallel-boosting-with-momentum.cc
rename to lossmin/minimizers/parallel-boosting-with-momentum.cc
diff --git a/minimizers/parallel-boosting-with-momentum.h b/lossmin/minimizers/parallel-boosting-with-momentum.h
similarity index 100%
rename from minimizers/parallel-boosting-with-momentum.h
rename to lossmin/minimizers/parallel-boosting-with-momentum.h
diff --git a/sample.cc b/sample.cc
index ee6d31c..1b688e2 100644
--- a/sample.cc
+++ b/sample.cc
@@ -9,9 +9,9 @@
 #include "lossmin/eigen-types.h"
 #include "lossmin/losses/loss-function.h"
 #include "lossmin/losses/inner-product-loss-function.h"
-#include "minimizers/gradient-evaluator.h"
-#include "minimizers/loss-minimizer.h"
-#include "minimizers/parallel-boosting-with-momentum.h"
+#include "lossmin/minimizers/gradient-evaluator.h"
+#include "lossmin/minimizers/loss-minimizer.h"
+#include "lossmin/minimizers/parallel-boosting-with-momentum.h"
 
 using namespace lossmin;