Commits

rride_a  committed 2412dc5

initial commit: main, precompiled headers and cmake settings

  • Participants

Comments (0)

Files changed (5)

File CMake/PrecompiledHeader.cmake

+##################################################################
+# Support macro to use a precompiled header
+# Usage:
+#   USE_PRECOMPILED_HEADER(HEADER_FILE SRC_FILE)
+##################################################################
+
+macro(use_precompiled_header TARGET_NAME HEADER_FILE SRC_FILE)
+  get_filename_component(HEADER ${HEADER_FILE} NAME)
+
+  if (MSVC)
+	#add_definitions()
+	set_target_properties( ${TARGET_NAME} PROPERTIES COMPILE_FLAGS "/Yu${HEADER} " )
+    set_source_files_properties(${SRC_FILE} PROPERTIES COMPILE_FLAGS /Yc"${HEADER}" )
+    
+  elseif (CMAKE_COMPILER_IS_GNUCXX)
+    # disabled because it seems to increase compile time
+    ## this is some serious hack... we definitely need native 
+    ## support in CMake for this!
+    ## we will generate the precompiled header via a workaround
+    ## first give the header a new name with the proper extension
+    #set(PRECOMP_HEADER ${CMAKE_CURRENT_BINARY_DIR}/hacked/${HEADER}.gch)
+    #configure_file(${HEADER_FILE} ${PRECOMP_HEADER} COPYONLY)
+    ## retrieve some info about the target's build settings
+    #get_target_property(${TARGET} PRECOMP_TYPE TYPE)
+    #if (PRECOMP_TYPE STREQUAL "SHARED_LIBRARY")
+    #  set(PRECOMP_LIBTYPE "SHARED")
+    #else ()
+    #  set(PRECOMP_LIBTYPE "STATIC")
+    #endif ()
+    #get_target_property(${TARGET} PRECOMP_DEFINITIONS COMPILE_DEFINITIONS)
+    #get_target_property(${TARGET} PRECOMP_FLAGS COMPILE_FLAGS)
+    #
+    ## add a new target which compiles the header
+    #add_library(__precomp_header ${PRECOMP_LIBTYPE} ${PRECOMP_HEADER})
+    #add_dependencies(${TARGET} __precomp_header)
+    #set_target_properties(__precomp_header PROPERTIES
+    #  COMPILE_DEFINITIONS ${PRECOMP_DEFINITIONS}
+    #  COMPILE_FLAGS ${PRECOMP_FLAGS}
+    #  HAS_CXX TRUE
+    #)
+    #set_source_files_properties(${PRECOMP_HEADER} PROPERTIES
+    #  HEADER_FILE_ONLY FALSE
+    #  KEEP_EXTENSION TRUE
+    #  COMPILE_FLAGS "-x c++-header"
+    #  LANGUAGE CXX
+    #)
+    #
+    ## finally, we need to ensure that gcc can find the precompiled header
+    ## this is another dirty hack
+    #include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/__precomp_header.dir/hacked")
+
+  endif ()
+endmacro(use_precompiled_header)

File CMakeLists.txt

+cmake_minimum_required(VERSION 2.8)
+##############################################
+# configure modules
+set(CMAKE_MODULE_PATH "${EBScheduler_SOURCE_DIR}/CMake" )
+include(PrecompiledHeader)
+
+##############################################
+# configure our project itself
+project(EBScheduler)
+
+set( SOURCE_FILES
+	Precompiled.h
+	Precompiled.cpp
+	Main.cpp
+	)
+
+add_executable( EBScheduler WIN32 ${SOURCE_FILES} )
+
+use_precompiled_header(EBScheduler Precompiled.h Precompiled.cpp )
+#include "Precompiled.h"
+
+#ifdef WIN32
+    int WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
+#endif
+{
+
+	return 0;
+}

File Precompiled.cpp

+#include "Precompiled.h"

File Precompiled.h

+// include some rarely changed stuff here
+
+#ifdef WIN32
+#	include <windows.h>
+#endif