Skip to content

Commit

Permalink
Simplified CMake files a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Juselius committed Jan 24, 2012
1 parent 3780c1d commit 77e650d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
4 changes: 2 additions & 2 deletions fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ link_directories(${PROJECT_BINARY_DIR}/src)
# Dummy target to satisfy dependency
add_custom_command (
OUTPUT
${PROJECT_BINARY_DIR}/src/Fortran/xcfun_autogen.f90
${PROJECT_BINARY_DIR}/src/xcfun_autogen.f90
DEPENDS
${PROJECT_BINARY_DIR}/src/geninterface
)

add_executable(example_fortran
example.f90
xcfun_module.f90
${PROJECT_BINARY_DIR}/src/Fortran/xcfun_autogen.f90
${PROJECT_BINARY_DIR}/src/xcfun_autogen.f90
)

set_target_properties(example_fortran
Expand Down
43 changes: 15 additions & 28 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

include_directories(taylor functionals)
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_BINARY_DIR}/src/include)
include_directories(
taylor
functionals
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src
)

set (BASE_LIB_SRCS
xcfun.cpp
Expand All @@ -14,48 +17,32 @@ set (BASE_LIB_SRCS
)

file (GLOB FUNCTIONAL_SRCS functionals/*.cpp)
set (GENERATED_FILES
${CMAKE_CURRENT_BINARY_DIR}/include/xcfun_autogen.h
${CMAKE_CURRENT_BINARY_DIR}/Fortran/xcfun_autogen.f90
)

add_library(xcfun ${BASE_LIB_SRCS}
${FUNCTIONAL_SRCS}
${GENERATED_FILES})
${GENERATED_FILES}
xcfun_autogen.h
xcfun_autogen.f90
)

add_executable(geninterface geninterface.cpp)

add_custom_target(interfaces ALL
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/include/xcfun_autogen.h
${CMAKE_CURRENT_BINARY_DIR}/Fortran/xcfun_autogen.f90
${CMAKE_CURRENT_BINARY_DIR}/xcfun_autogen.h
${CMAKE_CURRENT_BINARY_DIR}/xcfun_autogen.f90
)

add_custom_command (
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/include/xcfun_autogen.h
${CMAKE_CURRENT_BINARY_DIR}/Fortran/xcfun_autogen.f90
${CMAKE_CURRENT_BINARY_DIR}/xcfun_autogen.h
${CMAKE_CURRENT_BINARY_DIR}/xcfun_autogen.f90
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/Fortran
geninterface
functionals/list_of_parameters.h
${PROJECT_SOURCE_DIR}/include/xcfun.h
COMMAND geninterface
)

add_custom_command (
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/include
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/include
)
add_custom_command (
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/Fortran
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/Fortran
)

install(TARGETS xcfun ARCHIVE DESTINATION lib)

4 changes: 2 additions & 2 deletions src/geninterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ static const char *param_symbols[XC_NR_PARAMS+1] =
int main()
{
/* C interface */
FILE *of = fopen("include/xcfun_autogen.h","w");
FILE *of = fopen("xcfun_autogen.h","w");
fprintf(of,"enum xcfun_parameters {\n");
for (int i=0;i<XC_NR_PARAMS;i++)
fprintf(of,"%s,\n",param_symbols[i]);
fprintf(of,"XC_NR_PARAMS\n};\n");
fclose(of);

/* Fortran interface */
of = fopen("Fortran/xcfun_autogen.f90","w");
of = fopen("xcfun_autogen.f90","w");
fprintf(of,
"module xcfun_autogen\n"
"! this file is generated by src/geninterface.cpp - do not edit\n"
Expand Down
6 changes: 4 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/src/include)
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/src
)
link_directories(${PROJECT_BINARY_DIR}/src)

add_executable(funeval funeval.c)
Expand Down

0 comments on commit 77e650d

Please sign in to comment.