瀏覽代碼

removed auto-generated file in favor of simpler preprocessor definition

Former-commit-id: ec31d54c63c2b9c46eddf58433a6239b3ecae842
Daniel Crispell 9 年之前
父節點
當前提交
4df6057189
共有 3 個文件被更改,包括 19 次插入14 次删除
  1. 2 4
      tutorial/CMakeLists.txt
  2. 17 0
      tutorial/tutorial_shared_path.h
  3. 0 10
      tutorial/tutorial_shared_path.h.in

+ 2 - 4
tutorial/CMakeLists.txt

@@ -135,10 +135,8 @@ endif(UNIX AND NOT APPLE)
 #message(FATAL_ERROR ${SHARED_LIBRARIES})
 
 # Store location of tutorial/shared directory 
-set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared)
-message("tutorial_shared_path = ${TUTORIAL_SHARED_PATH}")
-configure_file(tutorial_shared_path.h.in "${CMAKE_BINARY_DIR}/tutorial_shared_path.h")
-include_directories(${CMAKE_BINARY_DIR})
+set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")
+add_definitions("-DTUTORIAL_SHARED_PATH=${TUTORIAL_SHARED_PATH}")
 
 # Chapter 1
 add_subdirectory("101_FileIO")

+ 17 - 0
tutorial/tutorial_shared_path.h

@@ -0,0 +1,17 @@
+#ifndef tutorial_shared_path_h_included
+#define tutorial_shared_path_h_included
+
+// convert the argument to a string constant
+#define STRINGIZE2(s) #s
+// need an extra level of macro indirection for preprocessor token stringification to work
+#define STRINGIZE(s) STRINGIZE2(s)
+
+#include <string>
+
+#ifndef TUTORIAL_SHARED_PATH
+const std::string tutorial_shared_path("../shared");
+#else
+const std::string tutorial_shared_path( STRINGIZE(TUTORIAL_SHARED_PATH) );
+#endif
+
+#endif

+ 0 - 10
tutorial/tutorial_shared_path.h.in

@@ -1,10 +0,0 @@
-#ifndef tutorial_shared_path_h_included
-#define tutorial_shared_path_h_included
-
-#include <string>
-
-const std::string tutorial_shared_path("@TUTORIAL_SHARED_PATH@");
-
-#endif
-
-