@ -44,6 +44,7 @@ int main(int argc, char** argv)
argParser . AddArg ( ArgDesc ( " -a " , true , 1 , " Add library projects, separated by ',' (ex: -a first,second,third) " ) ) ;
argParser . AddArg ( ArgDesc ( " -x " , true , 1 , " Add executable submodule projects, separated by ',' (ex: -x first,second,third) " ) ) ;
argParser . AddArg ( ArgDesc ( " -r " , true , 0 , " Remove the root project executable " ) ) ;
argParser . AddArg ( ArgDesc ( " -gs " , true , 0 , " Add git subsystem updating to the main cmake file. " ) ) ;
bool result = argParser . Parse ( ) ;
@ -223,7 +224,7 @@ int main(int argc, char** argv)
ofs < < " \n set(CMAKE_CXX_STANDARD " < < cversion < < " ) " ;
ofs < < " \n set(CMAKE_CXX_STANDARD_REQUIRED True) " ;
ofs < < " \n # setup target output directories " ;
ofs < < " \n \n # setup target output directories " ;
ofs < < " \n set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) " ;
ofs < < " \n set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) " ;
ofs < < " \n set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) " ;
@ -246,32 +247,61 @@ int main(int argc, char** argv)
ofs < < " \n \t PUBLIC src " ;
ofs < < " \n ) " ;
// Link to any libs that exist
ofs < < " \n \n target_link_directories(${PROJECT_NAME} " ;
for ( int i = 0 ; i < libraries . size ( ) ; i + + )
if ( argParser . ContainsOption ( " -gs " ) )
{
ofs < < " \n \t PRIVATE ../ " < < libraries [ i ] . c_str ( ) ;
ofs < < " \n \n # DOWNLOAD ALL SUBMODULES " ;
ofs < < " \n find_package(Git QUIET) " ;
ofs < < " \n if(GIT_FOUND AND EXISTS \" ${PROJECT_SOURCE_DIR}/.git \" ) " ;
ofs < < " \n # Update submodules as needed " ;
ofs < < " \n option(GIT_SUBMODULE \" Check submodules during build \" ON) " ;
ofs < < " \n if(GIT_SUBMODULE) " ;
ofs < < " \n message(STATUS \" Submodule update \" ) " ;
ofs < < " \n execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive " ;
ofs < < " \n WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} " ;
ofs < < " \n RESULT_VARIABLE GIT_SUBMOD_RESULT) " ;
ofs < < " \n if(NOT GIT_SUBMOD_RESULT EQUAL \" 0 \" ) " ;
ofs < < " \n message(FATAL_ERROR \" git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules \" ) " ;
ofs < < " \n endif() " ;
ofs < < " \n endif() " ;
ofs < < " \n endif() " ;
ofs < < " \n " ;
ofs < < " \n # CHECK THAT ALL SUBMODULES EXIST " ;
ofs < < " \n #if(NOT EXISTS \" ${PROJECT_SOURCE_DIR}/external/<PROJECT ROOT DIRECTORY>/CMakeLists.txt \" ) " ;
ofs < < " \n # message(FATAL_ERROR \" <PROJECT NAME> submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again. \" ) " ;
ofs < < " \n #endif() " ;
}
ofs < < " ) " ;
ofs < < " \n \n target_link_libraries(${PROJECT_NAME} " ;
// include the libraries and submodules
ofs < < " \n \n # add subdirectories here " ;
for ( int i = 0 ; i < libraries . size ( ) ; i + + )
{
ofs < < " " < < libraries [ i ] . c_str ( ) ;
ofs < < " \n add_subdirectory(src/ " < < libraries [ i ] . c_str ( ) < < " ) " ;
}
ofs < < " ) " ;
}
// include the libraries and submodules
for ( int i = 0 ; i < libraries . size ( ) ; i + + )
{
ofs < < " \n add_subdirectory(src/ " < < libraries [ i ] . c_str ( ) < < " ) " ;
}
for ( int i = 0 ; i < submods . size ( ) ; i + + )
{
ofs < < " \n add_subdirectory(src/ " < < submods [ i ] . c_str ( ) < < " ) " ;
}
for ( int i = 0 ; i < submods . size ( ) ; i + + )
{
ofs < < " \n add_subdirectory(src/ " < < submods [ i ] . c_str ( ) < < " ) " ;
// Link to any libs that exist or add space to link to submodules added through git
if ( libraries . size ( ) > 0 | | argParser . ContainsOption ( " -gs " ) )
{
ofs < < " \n \n target_link_directories(${PROJECT_NAME} " ;
for ( int i = 0 ; i < libraries . size ( ) ; i + + )
{
ofs < < " \n \t PRIVATE ../ " < < libraries [ i ] . c_str ( ) ;
}
ofs < < " ) " ;
ofs < < " \n \n target_link_libraries(${PROJECT_NAME} " ;
for ( int i = 0 ; i < libraries . size ( ) ; i + + )
{
ofs < < " " < < libraries [ i ] . c_str ( ) ;
}
ofs < < " ) " ;
}
}
ofs . close ( ) ;