PROJECT(CREA)
INCLUDE(Version.cmake)
-
+SET(CREA_VERBOSE_CMAKE TRUE)
SET(CREA_CMAKE_REL_PATH cmake)
SET(CREA_CMAKE_DIR ${PROJECT_SOURCE_DIR}/${CREA_CMAKE_REL_PATH})
INCLUDE(${CREA_CMAKE_DIR}/CREAMacros.cmake)
+
+#============================================================================
+# Builds and install the executable creaNewProject
+
+SET(EXE_NAME creaNewProject)
+SET(${EXE_NAME}_SOURCES creaNewProject.cpp)
+SET(${EXE_NAME}_CONSOLE FALSE)
+SET(${EXE_NAME}_LINK_LIBRARIES crea)
+
+CREA_ADD_WX_EXECUTABLE( ${EXE_NAME} )
+#============================================================================
+
+
+
+
+
+
+
+
+
+#============================================================================
# Installs creaNewProject.bat/.sh
# used to creates the file architecture for a new project
# and configures/installs the empty project structure used by creaNewProject
-
SET(INPUT_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NewProject)
FILE(GLOB_RECURSE NAMES RELATIVE ${INPUT_PROJECT_DIR} *.txt *.in *.cmake )
# Build tree
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/creaNewProject.sh.in
- ${EXECUTABLE_OUTPUT_PATH}/creaNewProject
+ ${EXECUTABLE_OUTPUT_PATH}/creaNewProject.sh
@ONLY IMMEDIATE
)
CREA_MKDIR(${EXECUTABLE_OUTPUT_PATH}/creaNewProject_data)
# Install tree
INSTALL(
- FILES ${EXECUTABLE_OUTPUT_PATH}/creaNewProject
+ FILES ${EXECUTABLE_OUTPUT_PATH}/creaNewProject.sh
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
--- /dev/null
+#include <creaWx.h>
+#include <wx/dirdlg.h>
+class myApp : public wxApp
+{
+public:
+ bool OnInit( );
+ int OnExit() { return true; }
+};
+
+IMPLEMENT_APP(myApp);
+CREA_WXMAIN_WITH_CONSOLE
+
+bool myApp::OnInit( )
+{
+ wxApp::OnInit();
+#ifdef __WXGTK__
+ //See http://www.wxwindows.org/faqgtk.htm#locale
+ setlocale(LC_NUMERIC, "C");
+#endif
+ wxInitAllImageHandlers();
+
+ wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
+
+ if (dir.IsEmpty()) return false;
+
+ wxString name = wxGetTextFromUser(_T("Enter project name"),
+ _T("creaNewProject"),
+ _T("New"));
+ if (name.IsEmpty()) return false;
+
+#if(_WIN32)
+ std::string command("creaNewProject.bat ");
+#else
+ std::string command("creaNewProject.sh ");
+#endif
+ command += crea::wx2std(dir) + " " + crea::wx2std(name);
+
+ if ( ! system ( command.c_str() ) )
+ {
+ wxMessageBox(_T("Done !"),_T("creaNewProject"),
+ wxOK | wxICON_INFORMATION);
+ }
+ else
+ {
+ wxString err("An error occured while running '");
+ err += crea::std2wx(command) + _T("'");
+ wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
+ }
+
+ return false;
+}
+
if [ -d $OUTPUT/${PROJECT} ]
then
echo "ERROR : Directory '$OUTPUT/${PROJECT}' already exists !"
- exit
+ exit 1
fi
echo "** Creating new project '$PROJECT' in folder '$OUTPUT'"
if [ ! -d $OUTPUT ]
then
echo "ERROR : Directory '$OUTPUT' does not exist !"
- exit
+ exit 1
fi
cp -R ${INPUT} "$OUTPUT/$PROJECT"
--- /dev/null
+MACRO(CREA_ADD_EXECUTABLE EXE_NAME)
+
+ IF(CREA_VERBOSE_CMAKE)
+ MESSAGE(STATUS "** Creating executable ${EXE_NAME}")
+ MESSAGE(STATUS " Sources : ${${EXE_NAME}_SOURCES}")
+ MESSAGE(STATUS " Link libs: ${${EXE_NAME}_LINK_LIBRARIES}")
+ ENDIF(CREA_VERBOSE_CMAKE)
+
+ IF(WIN32)
+ ADD_EXECUTABLE(${EXE_NAME} WIN32 ${${EXE_NAME}_SOURCES})
+ ELSE(WIN32)
+ ADD_EXECUTABLE(${EXE_NAME} ${${EXE_NAME}_SOURCES})
+ ENDIF(WIN32)
+
+ TARGET_LINK_LIBRARIES(${EXE_NAME} ${${EXE_NAME}_LINK_LIBRARIES})
+
+ INSTALL_TARGETS(/bin/ ${EXE_NAME})
+
+ENDMACRO(CREA_ADD_EXECUTABLE)
+
+
--- /dev/null
+MACRO(CREA_ADD_WX_EXECUTABLE EXE_NAME)
+
+
+ IF(USE_WXWIDGETS)
+ IF(CREA_VERBOSE_CMAKE)
+ MESSAGE(STATUS "** Creating wx executable ${EXE_NAME}")
+ MESSAGE(STATUS " Sources : ${${EXE_NAME}_SOURCES}")
+ MESSAGE(STATUS " Link libs: ${${EXE_NAME}_LINK_LIBRARIES}")
+ IF(WIN32)
+ MESSAGE(STATUS " Console : ${${EXE_NAME}_CONSOLE}")
+ ENDIF(WIN32)
+ ENDIF(CREA_VERBOSE_CMAKE)
+
+
+ IF(WIN32)
+ ADD_EXECUTABLE(${EXE_NAME} WIN32 ${${EXE_NAME}_SOURCES})
+ IF( ${${EXE_NAME}_CONSOLE} )
+ SET_TARGET_PROPERTIES(${EXE_NAME} PROPERTIES LINK_FLAGS /subsystem:console )
+ ENDIF( ${${EXE_NAME}_CONSOLE} )
+ ELSE(WIN32)
+ ADD_EXECUTABLE(${EXE_NAME} ${${EXE_NAME}_SOURCES})
+ ENDIF(WIN32)
+
+ TARGET_LINK_LIBRARIES(${EXE_NAME} ${${EXE_NAME}_LINK_LIBRARIES})
+ INSTALL_TARGETS(/bin/ ${EXE_NAME})
+ ENDIF(USE_WXWIDGETS)
+
+
+
+ENDMACRO(CREA_ADD_WX_EXECUTABLE)
+
+
--- /dev/null
+
+#========================================================================
+# Creates a directory if it does not exist
+MACRO(CREA_MKDIR DIR)
+ IF(NOT IS_DIRECTORY ${DIR})
+ MESSAGE(STATUS "* Creating directory '${DIR}'")
+ FILE(MAKE_DIRECTORY ${DIR})
+ ENDIF(NOT IS_DIRECTORY ${DIR})
+ENDMACRO(CREA_MKDIR)
+#========================================================================
#========================================================================
#========================================================================
-INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_PreventInSourceBuild.cmake )
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_AddExecutable.cmake )
#========================================================================
+#========================================================================
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_AddWxExecutable.cmake )
+#========================================================================
+#========================================================================
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_PreventInSourceBuild.cmake )
+#========================================================================
#========================================================================
-# Creates a directory if it does not exist
-MACRO(CREA_MKDIR DIR)
- IF(NOT IS_DIRECTORY ${DIR})
- MESSAGE(STATUS "* Creating directory '${DIR}'")
- FILE(MAKE_DIRECTORY ${DIR})
- ENDIF(NOT IS_DIRECTORY ${DIR})
-ENDMACRO(CREA_MKDIR)
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_mkdir.cmake )
#========================================================================
//===========================================================================
#ifdef USE_WXWIDGETS
+
+
+#if defined(_WIN32)
+// How to have a Console and wxWidgets
+// http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
+// In Visual C++ 6 (7 should be similar), to create an application that is both a console application
+// (cout's to the console are visible) and has a wxWidgets GUI,
+// you need to use the linker option "/subsystem:console" and the following code:
+#define CREA_WXMAIN_WITH_CONSOLE \
+ int main(int argc, char* argv[]) \
+ { \
+ return WinMain(::GetModuleHandle(NULL), NULL, \
+ ::GetCommandLine(), SW_SHOWNORMAL); \
+ }
+#else // defined(_WIN32)
+#define CREA_WXMAIN_WITH_CONSOLE
+#endif // defined(_WIN32)
+
+
+
+
namespace crea
{
//==================================================================