浏览代码

CMake files now build libraries and samples under Windows and MacOSX. MacOSX correctly creates bundles.

Lloyd Weehuizen 15 年之前
父节点
当前提交
9a649d49e7
共有 4 个文件被更改,包括 34 次插入59 次删除
  1. 32 56
      Build/CMakeLists.txt
  2. 0 1
      Build/cmake/SampleFileList.cmake
  3. 1 1
      Samples/invaders/src/main.cpp
  4. 1 1
      Samples/shell/src/macosx/ShellMacOSX.cpp

+ 32 - 56
Build/CMakeLists.txt

@@ -57,15 +57,7 @@ endif()
 #===================================
 
 # FreeType
-if(WIN32)
-	set(FREETYPE_INCLUDE_DIRS ../../support/freetype/include)
-	set(FREETYPE_LIBRARY freetype243MT.lib)
-	set(FREETYPE_LINK_DIRS ../../support/lib)
-	set(FREETYPE_FOUND TRUE)
-else()
-	find_package(Freetype REQUIRED)	
-endif()
-
+find_package(Freetype REQUIRED)	
 if(FREETYPE_FOUND)
 		include_directories(${FREETYPE_INCLUDE_DIRS})
 		link_directories(${FREETYPE_LINK_DIRS})
@@ -183,63 +175,57 @@ endif()
 
 # Build and link the samples
 macro(bl_sample NAME)
-    add_executable(${NAME} ${${NAME}_SRC_FILES}
-                           ${${NAME}_HDR_FILES}
-    )
+	if (WIN32)
+    	add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
+	elseif(APPLE)
+		add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
+    else()
+    	add_executable(${NAME} ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
+    endif()
     
     if (APPLE)
     	# We only support i386 for the samples as it still uses Carbon
-    	set_target_properties(${NAME} PROPERTIES
-    						OSX_ARCHITECTURES "i386;"
-    	)
+    	set_target_properties(${NAME} PROPERTIES OSX_ARCHITECTURES "i386;" )
     endif()
 
-    target_link_libraries(${NAME} shell)
+    target_link_libraries(${NAME} ${ARGN})
 endmacro()
 
 if(BUILD_SAMPLES)
     include(SampleFileList)
-    include(FindCarbon)
+	set(samples treeview customlog drag loaddocument)
     
     set(sample_LIBRARIES
     	shell 
     	RocketCore 
     	RocketControls
     	RocketDebugger
-	)
+    )
 
 	# Find OpenGL 
-	if(WIN32)
-	
-	else()
-    	find_package(OpenGL REQUIRED)
+	find_package(OpenGL REQUIRED)
     	   
-    	if(OPENGL_FOUND)
-        	include_directories(${OPENGL_INCLUDE_DIR})
-        	list(APPEND sample_LIBRARIES
-        		${OPENGL_LIBRARIES}
-        	)
-    	endif()
-
+    if(OPENGL_FOUND)
+    	include_directories(${OPENGL_INCLUDE_DIR})
+        list(APPEND sample_LIBRARIES ${OPENGL_LIBRARIES})
     endif()
     
-    # Find X11/Cocoa
+    # Set up required system libraries
     if(WIN32)
+		list(APPEND samples directx)
+    	list(APPEND sample_LIBRARIES d3d9 d3dx9)
     elseif(APPLE)
+		include(FindCarbon)
     	find_package(Carbon REQUIRED)
     	
     	if (Carbon_FOUND)
     		include_directories(${Carbon_INCLUDE_DIR})
-        	list(APPEND sample_LIBRARIES
-        		${Carbon_LIBRARIES}
-        	)
+        	list(APPEND sample_LIBRARIES ${Carbon_LIBRARIES})
     	endif()
     else()
     	find_package(X11 REQUIRED)
         if (X11_FOUND)
-        	list(APPEND sample_LIBRARIES
-        		${X11_LIBRARIES}
-        		)
+        	list(APPEND sample_LIBRARIES ${X11_LIBRARIES})
         endif()
     endif()
    
@@ -249,44 +235,34 @@ if(BUILD_SAMPLES)
     include_directories(${PROJECT_SOURCE_DIR}/Samples/shell/include)
 
     # Build and install sample shell library
-    add_library(shell ${shell_SRC_FILES}
-                      ${shell_HDR_FILES}
-    )
+    add_library(shell STATIC ${shell_SRC_FILES} ${shell_HDR_FILES})
     if (APPLE)
     	# We only support i386 for the samples as it still uses Carbon
-    	set_target_properties(shell PROPERTIES
-    						OSX_ARCHITECTURES "i386;"
-    	)
+    	set_target_properties(shell PROPERTIES OSX_ARCHITECTURES "i386;")
     endif()
 
-    target_link_libraries(${sample_LIBRARIES})
-
     install(TARGETS shell
             LIBRARY DESTINATION lib
             ARCHIVE DESTINATION lib
     )
 
-    list(APPEND samples treeview customlog drag loaddocument)
-
     # Build and install the basic samples
     foreach(sample ${samples})
-        bl_sample(${sample})
+        bl_sample(${sample} ${sample_LIBRARIES})
 
         # The samples always set this as their current working directory
         install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/${sample})
-
-        install(TARGETS ${sample}
-                RUNTIME DESTINATION ${SAMPLES_DIR}
-        )
+        install(TARGETS ${sample} 
+        	RUNTIME DESTINATION ${SAMPLES_DIR}/${sample}
+        	BUNDLE DESTINATION ${SAMPLES_DIR})
     endforeach()
 
     # Build and install invaders sample
-    bl_sample(invaders)
+    bl_sample(invaders ${sample_LIBRARIES})
     install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
-    install(TARGETS invaders
-            RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
-    )
-
+    install(TARGETS invaders 
+    	RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
+    	BUNDLE DESTINATION ${SAMPLES_DIR})
 endif()
 
 

+ 0 - 1
Build/cmake/SampleFileList.cmake

@@ -167,7 +167,6 @@ set(shell_SRC_FILES
 
 # Deal with platform specific sources for sample shell
 if(WIN32)
-	list(APPEND samples basic_directx)
 	list(APPEND shell_SRC_FILES
 		${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/ShellWin32.cpp
 		${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/InputWin32.cpp

+ 1 - 1
Samples/invaders/src/main.cpp

@@ -61,7 +61,7 @@ int main(int, char**)
 #endif
 {
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise("./") ||
+	if (!Shell::Initialise("../Samples/invaders/") ||
 		!Shell::OpenWindow("Rocket Invaders from Mars", true))
 	{
 		Shell::Shutdown();

+ 1 - 1
Samples/shell/src/macosx/ShellMacOSX.cpp

@@ -83,7 +83,7 @@ bool Shell::Initialise(const Rocket::Core::String& path)
 	CFRelease(executable_posix_file_name);
 	CFRelease(executable_url);
 
-	file_interface = new ShellFileInterface(executable_path + "../../../");
+	file_interface = new ShellFileInterface(executable_path + "../../../" + path);
 	Rocket::Core::SetFileInterface(file_interface);
 
 	return true;