# cmake create full directory path on Linux

**URL:** <https://discourse.cmake.org/t/cmake-create-full-directory-path-on-linux/15492>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [February 3, 2026, 1:16pm UTC](https://discourse.cmake.org/t/cmake-create-full-directory-path-on-linux/15492 "2026-02-03T13:16:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon74639460](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@anon74639460](https://discourse.cmake.org/u/anon74639460)\
**Post date:** [February 3, 2026, 1:16pm UTC](https://discourse.cmake.org/t/cmake-create-full-directory-path-on-linux/15492/1 "2026-02-03T13:16:44Z")

</div>

I’m on Ubuntu 18.04

cmake version 4.2.1

Trying to bring libtool into my project because the version of libtool on 18.04 doesn’t work properly when it comes to dependencies of a plugin you just loaded.

```auto
ExternalProject_Add(
ls_libtool
PREFIX ${CMAKE_BINARY_DIR}/ls_libtool
SOURCE_DIR ${CMAKE_BINARY_DIR}/ls_libtool
URL https://ftp.gnu.org/gnu/libtool/libtool-2.5.4.tar.gz
DOWNLOAD_NO_PROGRESS ON
DOWNLOAD_EXTRACT_TIMESTAMP false
CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/ls_libtool/configure --prefix={CMAKE_BINARY_DIR}/ls_libtool “CFLAGS=-g -O0 ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}”
BUILD_COMMAND make

)

ExternalProject_Add_Step(
ls_libtool
pre_download
COMMENT “stupid touch directory”
file(MAKE_DIRECTORY “${CMAKE_BINARY_DIR}/ls_libtool/src/ls_libtool-stamp”)
COMMAND ${CMAKE_COMMAND} -E make_directory “${CMAKE_BINARY_DIR}/ls_libtool/src/ls_libtool-stamp”
DEPENDEES download
)

```

No matter what the full directory path that the download wants to touch is not created.

Have looked at the following and found no help.

> <https://stackoverflow.com/questions/3702115/creating-a-directory-in-cmake>

[https://cmake.org/cmake/help/latest/command/cmake\_path.html](https://cmake.org/cmake/help/latest/command/cmake_path.html)

```auto
developer@developer-U1804-VirtualBox:~/github_projects/ls-cs$ tree /home/developer/github_projects/LsCs_local_build/ls_libtool
/home/developer/github_projects/LsCs_local_build/ls_libtool
├── aclocal.m4
├── AUTHORS
├── bootstrap
├── bootstrap.conf
├── build-aux
│ ├── announce-gen
│ ├── compile
│ ├── config.guess
│ ├── config.sub
│ ├── depcomp
│ ├── do-release-commit-and-tag
│ ├── edit-readme-alpha
│ ├── extract-trace
│ ├── funclib.sh
│ ├── gendocs.sh
│ ├── git-version-gen
│ ├── gnupload
│ ├── gnu-web-doc-update
│ ├── inline-source
│ ├── install-sh
│ ├── ltmain.in
│ ├── ltmain.sh
│ ├── mdate-sh
│ ├── missing
│ ├── no-bogus-m4-defines
│ ├── options-parser
│ ├── test-driver
│ ├── texinfo.tex
│ ├── update-copyright
│ ├── useless-if-before-free
│ └── vc-list-files
├── cfg.mk
├── ChangeLog
├── config-h.in
├── configure
├── configure.ac
├── COPYING
├── doc
│ ├── fdl.texi
│ ├── gendocs_template
│ ├── libtool.1
│ ├── libtool.info
│ ├── libtool.info-1
│ ├── libtool.info-2
│ ├── libtoolize.1
│ ├── libtool.texi
│ ├── notes.texi
│ ├── notes.txt
│ ├── PLATFORMS
│ ├── stamp-vti
│ └── version.texi
├── gnulib-tests
│ ├── init.sh
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── test-all-shells.sh
│ ├── test-funclib-quote.sh
│ ├── test-init.sh
│ ├── test-option-parser-helper
│ ├── test-option-parser.sh
│ ├── test-update-copyright.sh
│ ├── test-vc-list-files-cvs.sh
│ └── test-vc-list-files-git.sh
├── GNUmakefile
├── INSTALL
├── libltdl
│ ├── aclocal.m4
│ ├── config-h.in
│ ├── configure
│ ├── configure.ac
│ ├── COPYING.LIB
│ ├── libltdl
│ │ ├── lt__alloc.h
│ │ ├── lt__argz_.h
│ │ ├── lt__dirent.h
│ │ ├── lt_dlloader.h
│ │ ├── lt_error.h
│ │ ├── lt__glibc.h
│ │ ├── lt__private.h
│ │ ├── lt__strl.h
│ │ ├── lt_system.h
│ │ └── slist.h
│ ├── loaders
│ │ ├── dld_link.c
│ │ ├── dlopen.c
│ │ ├── dyld.c
│ │ ├── load_add_on.c
│ │ ├── loadlibrary.c
│ │ ├── preopen.c
│ │ └── shl_load.c
│ ├── lt__alloc.c
│ ├── lt__argz.c
│ ├── lt__dirent.c
│ ├── ltdl.c
│ ├── ltdl.h
│ ├── lt_dlloader.c
│ ├── ltdl.mk
│ ├── lt_error.c
│ ├── lt__strl.c
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── README
│ ├── slist.c
│ └── stamp-mk
├── libtoolize.in
├── m4
│ ├── 00gnulib.m4
│ ├── autobuild.m4
│ ├── gnulib-common.m4
│ ├── gnulib-comp.m4
│ ├── libtool.m4
│ ├── ltargz.m4
│ ├── ltdl.m4
│ ├── lt~obsolete.m4
│ ├── ltoptions.m4
│ ├── ltsugar.m4
│ ├── ltversion.in
│ ├── ltversion.m4
│ ├── m4.m4
│ └── zzgnulib.m4
├── maint.mk
├── Makefile.am
├── Makefile.in
├── NEWS
├── README
├── tests
│ ├── am-subdir.at
│ ├── archive-in-archive.at
│ ├── bindir.at
│ ├── bug_42313.at
│ ├── bug_62343.at
│ ├── bug_71489.at
│ ├── cdemo.at
│ ├── cmdline_wrap.at
│ ├── configure-funcs.at
│ ├── configure-iface.at
│ ├── convenience.at
│ ├── ctor.at
│ ├── cwrapper.at
│ ├── darwin.at
│ ├── demo.at
│ ├── depdemo.at
│ ├── deplib-in-subdir.at
│ ├── deplibs-ident.at
│ ├── deplibs-mingw.at
│ ├── destdir.at
│ ├── dlloader-api.at
│ ├── dumpbin-symbols.at
│ ├── duplicate_conv.at
│ ├── duplicate_deps.at
│ ├── duplicate_members.at
│ ├── early-libtool.at
│ ├── exceptions.at
│ ├── execute-mode.at
│ ├── exeext.at
│ ├── export.at
│ ├── export-def.at
│ ├── f77demo.at
│ ├── fail.at
│ ├── fcdemo.at
│ ├── flags.at
│ ├── help.at
│ ├── indirect_deps.at
│ ├── infer-tag.at
│ ├── inherited_flags.at
│ ├── install.at
│ ├── lalib-syntax.at
│ ├── libtool.at
│ ├── libtoolize.at
│ ├── link-order2.at
│ ├── link-order.at
│ ├── loadlibrary.at
│ ├── localization.at
│ ├── lt_dladvise.at
│ ├── ltdl-api.at
│ ├── lt_dlexit.at
│ ├── ltdl-libdir.at
│ ├── lt_dlopen_a.at
│ ├── lt_dlopen.at
│ ├── lt_dlopenext.at
│ ├── mdemo.at
│ ├── need_lib_prefix.at
│ ├── nocase.at
│ ├── no-executables.at
│ ├── nonrecursive.at
│ ├── old-m4-iface.at
│ ├── package.m4
│ ├── pic_flag.at
│ ├── recursive.at
│ ├── resident.at
│ ├── runpath-in-lalib.at
│ ├── search-path.at
│ ├── shlibpath.at
│ ├── slist.at
│ ├── standalone.at
│ ├── static.at
│ ├── stresstest.at
│ ├── subproject.at
│ ├── sysroot.at
│ ├── tagdemo.at
│ ├── template.at
│ ├── testsuite
│ ├── testsuite.at
│ ├── versioning.at
│ └── with-pic.at
├── THANKS
└── TODO

8 directories, 199 files

```

There has to be a simple solution for this.

Appreciate any assistance.

---

<div class="post-metadata">

**Author:** ![anon74639460](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@anon74639460](https://discourse.cmake.org/u/anon74639460)\
**Post date:** [February 4, 2026, 9:58pm UTC](https://discourse.cmake.org/t/cmake-create-full-directory-path-on-linux/15492/2 "2026-02-04T21:58:01Z")

</div>

Answering my own question.

There are some serious bugs in ExternaProject\_Add keywords. If you use both PREFIX and SOURCE\_DIR; Prefix will not create the other directories. SOURCE\_DIR will not create what URL wants, and much nastiness happens.

This worked.

# 

```auto
CMake is an odd duck. If you provide SOURCE_DIR definition for

external project, PREFIX will not create the other directories.

CMake ASS-U-ME-s all external projects are CMAKE builds. Not

the case with libtool and so many other things.

The hacky looking path for the configure command is a result of

CMake forcing its own directory structure on external project.

include(ExternalProject)

ExternalProject_Add(
ls_libtool
PREFIX “${CMAKE_BINARY_DIR}/ls_libtool”
DOWNLOAD_DIR “${CMAKE_BINARY_DIR}”
URL https://ftp.gnu.org/gnu/libtool/libtool-2.5.4.tar.gz
DOWNLOAD_NO_PROGRESS ON
DOWNLOAD_EXTRACT_TIMESTAMP false
CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/ls_libtool/src/ls_libtool/configure --prefix=${CMAKE_BINARY_DIR}/ls_libtool/install “CFLAGS=-g -O0 ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}”
BUILD_COMMAND make

)

```

sorry, that preformatted took out my pound sign comment markers.
