cmake_minimum_required (VERSION 3.0)
project (ccbuild)

set (CMAKE_CXX_STANDARD 17)

find_package(FLEX)
FLEX_TARGET(SourceScanner "src/sourceScanner/lexer"  "src/sourceScanner/yylex.cc" )
string(SUBSTRING ${FLEX_VERSION} 0 1 FLEX_VERSION_MAJOR)
string(SUBSTRING ${FLEX_VERSION} 2 1 FLEX_VERSION_MINOR)

add_definitions(-DVERSION="v2.0.7-39-gdf7b35c" -DFLEX_VERSION_MAJOR=${FLEX_VERSION_MAJOR} -DFLEX_VERSION_MINOR=${FLEX_VERSION_MINOR})
link_libraries(gomp bobcat gnutls)
add_definitions(-fopenmp)
add_executable(ccbuild src/ccbuild.cc src/MD5Info/statics.cc src/MD5Info/save.cc src/MD5Info/old.cc src/MD5Info/load.cc src/MD5Info/hashFilenameFor.cc src/MD5Info/getInstance.cc src/MD5Info/destroy.cc src/MD5Info/contentHash.cc src/MD5Info/MD5Info.cc src/options/statics.cc src/system/username.cc src/system/uname.cc src/system/trimmed.cc src/system/trim.cc src/system/system.cc src/system/statics.cc src/system/sleep.cc src/system/resolveTest.cc src/system/projectName.cc src/system/parseArguments.cc src/system/mkdtemp.cc src/system/md5.cc src/system/makefileForAll.cc src/system/makefileFor.cc src/system/localSourcesInto.cc src/system/lib.cc src/system/inspect.cc src/system/icmake.cc src/system/exit.cc src/system/dotgraphForAll.cc src/system/dotgraphFor.cc src/system/distclean.cc src/system/destroy.cc src/system/depsFor.cc src/system/collectTargets.cc src/system/clean.cc src/system/check.cc src/system/changeTo.cc src/system/buildAll.cc src/system/build.cc src/system/batchCompile.cc src/system/addArguments.cc src/system/aapForAll.cc src/system/aapFor.cc src/string/toUpper.cc src/string/replace.cc src/globallocks/statics.cc src/globals/statics.cc src/globals/indexoperator.cc src/globals/globals.cc src/globals/getInstance.cc src/globals/destroy.cc src/fileSystem/touch.cc src/fileSystem/rmIfExists.cc src/fileSystem/rmDirectoryIfExists.cc src/fileSystem/rename.cc src/fileSystem/recursiveGlobDirectoriesInto.cc src/fileSystem/newer.cc src/fileSystem/modTime.cc src/fileSystem/isReadable.cc src/fileSystem/isDirectory.cc src/fileSystem/globSourceFilesInto.cc src/fileSystem/globInto.cc src/fileSystem/globFilesInto.cc src/fileSystem/globDirectoriesInto.cc src/fileSystem/fileName.cc src/fileSystem/fileExists.cc src/fileSystem/ensureDirectory.cc src/fileSystem/directoryName.cc src/fileSystem/cwd.cc src/fileSystem/cleanPath.cc src/fileSystem/baseName.cc src/fileSystem/absolutePath.cc src/problem/problem.cc src/resolver/statics.cc src/resolver/resolver.cc src/resolver/resolveInto.cc src/resolver/resolve.cc src/resolver/loadIfExists.cc src/resolver/getInstance.cc src/resolver/expand.cc src/resolver/destroy.cc src/compiler/statics.cc src/compiler/splitInto.cc src/compiler/precompileCommand.cc src/compiler/precompile.cc src/compiler/operator_add.cc src/compiler/linkCommand.cc src/compiler/link.cc src/compiler/libCommand.cc src/compiler/lib.cc src/compiler/countFirstLinkerArguments.cc src/compiler/compileCommand.cc src/compiler/compile.cc src/compiler/cls.cc src/compiler/ar.cc src/compiler/addObject.cc src/compiler/addArgument.cc src/sources/statics.cc src/sources/sources.cc src/sources/reloadStaleSources.cc src/sources/indexoperator.cc src/sources/getInstance.cc src/sources/erase.cc src/sources/destroy.cc src/source/upToDate.cc src/source/stale.cc src/source/source.cc src/source/setType.cc src/source/scan.cc src/source/reload.cc src/source/producesOutput.cc src/source/outputFilename.cc src/source/markAsDone.cc src/source/isObjectTarget.cc src/source/isLocalHeader.cc src/source/isLibTarget.cc src/source/isInternalHeader.cc src/source/isHeader.cc src/source/isBinTarget.cc src/source/hasSourceExtension.cc src/source/genDeps.cc src/source/directory.cc src/source/directDeps.cc src/source/dependencies.cc src/source/changed.cc src/source/buildObjectTarget.cc src/source/buildHeader.cc src/source/buildBinTarget.cc src/source/build.cc src/source/basenameWithoutExtension.cc src/sourceScanner/storeLocal.cc src/sourceScanner/storeIgnore.cc src/sourceScanner/storeGlobal.cc src/sourceScanner/sourceScanner.cc src/sourceScanner/includes.cc src/sourceScanner/hasMainFunction.cc src/sourceScanner/hasDefine.cc src/arguments/values.cc src/arguments/value.cc src/arguments/statics.cc src/arguments/outputOptions.cc src/arguments/initialize.cc src/arguments/getInstance.cc src/arguments/flagged.cc src/arguments/destroy.cc src/arguments/clear.cc src/arguments/arguments.cc  ${FLEX_SourceScanner_OUTPUTS})
install(TARGETS ccbuild DESTINATION bin)
install(FILES doc/ccbuild/ccbuild.1 DESTINATION share/man/man1)
